473,372 Members | 836 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 8672
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ron Adam | last post by:
Is it possible to match a string to regular expression pattern instead of the other way around? For example, instead of finding a match within a string, I want to find out, (pass or fail), if...
8
by: Michael McGarry | last post by:
Hi, I am horrible with Regular Expressions, can anyone recommend a book on it? Also I am trying to parse the following string to extract the number after load average. ".... load average:...
1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
11
by: Ron Rohrssen | last post by:
Slightly off topic.... How can I write a regex that limits user input to 3 digits in the range of 1-128? I've been trying \d{1,128} but this allows for a match on more than 3 digits. ...
1
by: Christian H | last post by:
Hello! I'm trying to create and extract the values of a Print-Range , "Print page" dialog. I have a textfield where the user can enter the pages they whish to print. The format can be:...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
11
by: Steve | last post by:
Hi All, I'm having a tough time converting the following regex.compile patterns into the new re.compile format. There is also a differences in the regsub.sub() vs. re.sub() Could anyone lend...
1
by: AAaron123 | last post by:
I found this on the Internet and tried a few of them and they worked in VS2008. Actually it was in a different form but I converted to make a smaller file. The data is the same as the original. ...
47
by: Henning_Thornblad | last post by:
What can be the cause of the large difference between re.search and grep? This script takes about 5 min to run on my computer: #!/usr/bin/env python import re row="" for a in range(156000):...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.