Xymon Mailing List Archive search

PCRE Assistance

5 messages in this thread

list Ryan Novosielski · Fri, 26 Mar 2010 16:17:48 -0400 ·
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm feeling rather dopey at not being able to figure this out, but bear
with me.

I'm trying to define a regex that will match, among other things, a line
that begins with: netmon- and any number of characters that follow it,
and then ends with my domain name. The two I need it to match right now
are: "netmon-int.umdnj.edu" and "netmon-ext.umdnj.edu" but there may be
others going forward.

Here is my example:

%(bbdisplay|xymon|katahdin|^netmon-*).umdnj.edu

I was suspicious of the ^, so I tried removing it -- no change. So far
I've tried this list of things:

%(bbdisplay|xymon|katahdin|netmon-*).umdnj.edu
%(bbdisplay|xymon|katahdin|^netmon\-*).umdnj.edu
%(bbdisplay|xymon|katahdin|netmon\-*).umdnj.edu

...maybe one or two others. When I try either of the two hostnames I'm
trying to match with pcretest, I get "No match". Can anyone point me in
the right direction? It's surely something simple.

- --
 ---- _  _ _  _ ___  _  _  _
 |Y#| |  | |\/| |  \ |\ |  | |Ryan Novosielski - Systems Programmer II
 |$&| |__| |  | |__/ | \| _| |user-ae4522577e16@xymon.invalid - 973/972.0922 (2-0922)
 \__/ Univ. of Med. and Dent.|IST/CST - NJMS Medical Science Bldg - C630
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkutFmsACgkQmb+gadEcsb5ljQCfeHH215LC1dLo3guwlJkPzp4H
6MIAnRILcRuLfvoAsNY5/5uBLNM+QkEH
=eMzo
-----END PGP SIGNATURE-----
list Daniel J McDonald · Fri, 26 Mar 2010 15:37:26 -0500 ·
On Fri, 2010-03-26 at 16:17 -0400, Ryan Novosielski wrote:
Here is my example:

%(bbdisplay|xymon|katahdin|^netmon-*).umdnj.edu
That matches netmon followed by zero or more dashes.  You probably want:

%(bbdisplay|xymon|katahdin|^netmon-.+)\.umdnj\.edu

-- 
Daniel J McDonald, CCIE # 2495, CISSP # 78281, CNX
www.austinenergy.com
list Asif Iqbal · Fri, 26 Mar 2010 16:39:07 -0400 ·
quoted from Ryan Novosielski
On Fri, Mar 26, 2010 at 4:17 PM, Ryan Novosielski <user-ae4522577e16@xymon.invalid> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm feeling rather dopey at not being able to figure this out, but bear
with me.

I'm trying to define a regex that will match, among other things, a line
that begins with: netmon- and any number of characters that follow it,
and then ends with my domain name. The two I need it to match right now
are: "netmon-int.umdnj.edu" and "netmon-ext.umdnj.edu" but there may be
others going forward.
this should catch it

%netmon-.*
quoted from Ryan Novosielski

Here is my example:

%(bbdisplay|xymon|katahdin|^netmon-*).umdnj.edu

I was suspicious of the ^, so I tried removing it -- no change. So far
I've tried this list of things:

%(bbdisplay|xymon|katahdin|netmon-*).umdnj.edu
%(bbdisplay|xymon|katahdin|^netmon\-*).umdnj.edu
%(bbdisplay|xymon|katahdin|netmon\-*).umdnj.edu

...maybe one or two others. When I try either of the two hostnames I'm
trying to match with pcretest, I get "No match". Can anyone point me in
the right direction? It's surely something simple.

- --
 ---- _  _ _  _ ___  _  _  _
 |Y#| |  | |\/| |  \ |\ |  | |Ryan Novosielski - Systems Programmer II
 |$&| |__| |  | |__/ | \| _| |user-ae4522577e16@xymon.invalid - 973/972.0922 (2-0922)
 \__/ Univ. of Med. and Dent.|IST/CST - NJMS Medical Science Bldg - C630
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkutFmsACgkQmb+gadEcsb5ljQCfeHH215LC1dLo3guwlJkPzp4H
6MIAnRILcRuLfvoAsNY5/5uBLNM+QkEH
=eMzo
-----END PGP SIGNATURE-----

-- 

Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
list Ryan Novosielski · Fri, 26 Mar 2010 16:41:50 -0400 ·
quoted from Daniel J McDonald
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel J McDonald wrote:
On Fri, 2010-03-26 at 16:17 -0400, Ryan Novosielski wrote:
Here is my example:

%(bbdisplay|xymon|katahdin|^netmon-*).umdnj.edu
That matches netmon followed by zero or more dashes.  You probably want:

%(bbdisplay|xymon|katahdin|^netmon-.+)\.umdnj\.edu
Indeed I do! Thank you! Did not realize that the */+ modifiers refer to
the thing immediately before them.
quoted from Asif Iqbal

- --
 ---- _  _ _  _ ___  _  _  _
 |Y#| |  | |\/| |  \ |\ |  | |Ryan Novosielski - Systems Programmer II
 |$&| |__| |  | |__/ | \| _| |user-ae4522577e16@xymon.invalid - 973/972.0922 (2-0922)
 \__/ Univ. of Med. and Dent.|IST/CST - NJMS Medical Science Bldg - C630
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkutHA4ACgkQmb+gadEcsb5MfACgi5/YflKwtyCGwZ4vmmHRmIZd
c24AoMYKOLS9THqEXf2/mVdpf4gFpMXF
=m57N
-----END PGP SIGNATURE-----
list Odinn · Fri, 26 Mar 2010 13:45:52 -0700 (PDT) ·
Careful not to confuse globbing with regex

%(bbdisplay|xymon|katahdin|^netmon-.*).umdnj.edu
 
You were almost there.  * means to match the previous character 0 or more times

. is any character, so .* is match any character 0 or more times.

.+ would be to match any character 1 or more times

This is different than globbing, where * means any character 0 or more times.

Common mistake for those not familiar with the intricacies or regex vs globbing.
--


Jim Sloan


Just remember, today is the day you thought tomorrow was going to be yesterday.
quoted from Ryan Novosielski


----- Original Message ----
From: Ryan Novosielski <user-ae4522577e16@xymon.invalid>
To: user-ae9b8668bcde@xymon.invalid
Sent: Fri, March 26, 2010 4:17:48 PM
Subject: [hobbit] PCRE Assistance

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm feeling rather dopey at not being able to figure this out, but bear
with me.

I'm trying to define a regex that will match, among other things, a line
that begins with: netmon- and any number of characters that follow it,
and then ends with my domain name. The two I need it to match right now
are: "netmon-int.umdnj.edu" and "netmon-ext.umdnj.edu" but there may be
others going forward.

Here is my example:

%(bbdisplay|xymon|katahdin|^netmon-*).umdnj.edu

I was suspicious of the ^, so I tried removing it -- no change. So far
I've tried this list of things:

%(bbdisplay|xymon|katahdin|netmon-*).umdnj.edu
%(bbdisplay|xymon|katahdin|^netmon\-*).umdnj.edu
%(bbdisplay|xymon|katahdin|netmon\-*).umdnj.edu

...maybe one or two others. When I try either of the two hostnames I'm
trying to match with pcretest, I get "No match". Can anyone point me in
the right direction? It's surely something simple.

- --
---- _  _ _  _ ___  _  _  _
|Y#| |  | |\/| |  \ |\ |  | |Ryan Novosielski - Systems Programmer II
|$&| |__| |  | |__/ | \| _| |user-ae4522577e16@xymon.invalid - 973/972.0922 (2-0922)
\__/ Univ. of Med. and Dent.|IST/CST - NJMS Medical Science Bldg - C630
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkutFmsACgkQmb+gadEcsb5ljQCfeHH215LC1dLo3guwlJkPzp4H
6MIAnRILcRuLfvoAsNY5/5uBLNM+QkEH
=eMzo
-----END PGP SIGNATURE-----