469,336 Members | 5,507 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

regular expression on a range of number...

hi all,

i am setting up swatch (syslog monitoring) for email alert. i have a
cisco 2924 switch and i wanna to ignore alarm from fastethernet0/0-22,
but keep alarm on 0/23-24. i think the following statement works, but
can i shorten the statement?

/FastEthernet0\/[0-9],/ || /FastEthernet0\/1[0-9],/ ||
/FastEthernet0\/2[01],/

thanks
Jul 19 '05 #1
3 8576
Louis wrote:
i am setting up swatch (syslog monitoring) for email alert. i have a
cisco 2924 switch and i wanna to ignore alarm from fastethernet0/0-22,
but keep alarm on 0/23-24. i think the following statement works, but
can i shorten the statement?

/FastEthernet0\/[0-9],/ || /FastEthernet0\/1[0-9],/ ||
/FastEthernet0\/2[01],/


/FastEthernet0\/(?:1?[0-9]|2[0-2]),/

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Jul 19 '05 #2
Gunnar Hjalmarsson <no*****@gunnar.cc> wrote in message news:<gB********************@newsc.telia.net>...
/FastEthernet0\/(?:1?[0-9]|2[0-2]),/


Thanks a ton...

I think I understand the last part '|2[0-2]'. Can you explain
'?:1?[0-9]'? Or ':' -? '|'?

Thanks
Jul 19 '05 #3
Louis wrote:
Gunnar Hjalmarsson wrote:

/FastEthernet0\/(?:1?[0-9]|2[0-2]),/


Thanks a ton...

I think I understand the last part '|2[0-2]'. Can you explain
'?:1?[0-9]'? Or ':' -? '|'?


(?: ) is to be seen together, and is for non-capturing grouping.

But, honestly, there is absolutely no reason why I would try to
explain regex syntax, since it's explained in the docs much better
than I ever would be able to do. See for instance:

http://www.perldoc.com/perl5.8.4/pod/perlretut.html

P.S. You can shorten it with another three characters:

/FastEthernet0\/(?:1?\d|2[0-2]),/

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Ron Adam | last post: by
8 posts views Thread by Michael McGarry | last post: by
11 posts views Thread by Ron Rohrssen | last post: by
1 post views Thread by Christian H | last post: by
7 posts views Thread by Billa | last post: by
25 posts views Thread by Mike | last post: by
1 post views Thread by AAaron123 | last post: by
47 posts views Thread by Henning_Thornblad | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.