Xymon Mailing List Archive search

PCRE expression question

4 messages in this thread

list Galen Johnson · Wed, 18 Apr 2007 11:19:07 -0400 ·
Hey,

I know I'm just missing something simple and it's probably something I've overlooked but I'm having an issue with a regex in one of my port tests...

This works:

PORT "LOCAL=%[\.:](8611|8621|8631)$" state=LISTEN

But this doesn't...

PORT "LOCAL=%[\.:]86?1$" state=LISTEN 

I'm hoping fresh eyes will see what stupid thing I've missed...

=G=
list Paul van Eldijk · Wed, 18 Apr 2007 17:43:31 +0200 ·
Galen Johnson schreef:
quoted from Galen Johnson
Hey,

I know I'm just missing something simple and it's probably something I've overlooked but I'm having an issue with a regex in one of my port tests...

This works:

PORT "LOCAL=%[\.:](8611|8621|8631)$" state=LISTEN

But this doesn't...

PORT "LOCAL=%[\.:]86?1$" state=LISTEN 
6? matches zero or one 6, so that is not what you want.

6. matches a six, followed by any character
6[1-3] matches a 6 followed by a one, two or three.

So you want:
PORT "LOCAL=%[\.:]86[1-3]1$" state=LISTEN

HTH,
Paul
list Charles Goyard · Wed, 18 Apr 2007 17:54:00 +0200 ·
Hi,
quoted from Galen Johnson

Galen Johnson wrote :
This works:

PORT "LOCAL=%[\.:](8611|8621|8631)$" state=LISTEN

But this doesn't...

PORT "LOCAL=%[\.:]86?1$" state=LISTEN 
I'm hoping fresh eyes will see what stupid thing I've missed...
That's because "?" matches 0 or 1 character, and applies to the 6. Try :

PORT "LOCAL=%[\.:]86[0-9]1$" state=LISTEN

(means 86 then some number, then 1, then end)

? has not the same meaning in pcre than in shell.

-- 
Charles Goyard - user-a6cdca7046e2@xymon.invalid - (+33) 1 45 38 01 31
Orange Business Services - online multimedia  // ingénierie
list Galen Johnson · Wed, 18 Apr 2007 12:24:33 -0400 ·
I tried the '.' as well with the same issue (kept showing 0 instances)...I think I'll just go with the [1-9]...thanks. 

=G=
quoted from Paul van Eldijk

-----Original Message-----
From: Paul van Eldijk [mailto:user-86c97c6293b5@xymon.invalid] 
Sent: Wednesday, April 18, 2007 11:44 AM
To: user-ae9b8668bcde@xymon.invalid
Subject: Re: [hobbit] PCRE expression question

Galen Johnson schreef:
Hey,

I know I'm just missing something simple and it's probably something I've overlooked but I'm having an issue with a regex in one of my port tests...

This works:

PORT "LOCAL=%[\.:](8611|8621|8631)$" state=LISTEN

But this doesn't...

PORT "LOCAL=%[\.:]86?1$" state=LISTEN
6? matches zero or one 6, so that is not what you want.

6. matches a six, followed by any character 6[1-3] matches a 6 followed by a one, two or three.

So you want:
PORT "LOCAL=%[\.:]86[1-3]1$" state=LISTEN

HTH,
Paul