regex question

Dan Shoop shoop at iwiring.net
Thu Apr 5 10:38:36 PDT 2007


At 11:31 AM -0400 4/5/07, János wrote:
>I need to match some strings that must start 
>with any of 'S', 'A', 'C' or 'N', followed by 
>two digits followed by a '-' /dash/, followed by 
>one to six digits.
>
>So I created the following one:
>
>"^[ACNS][0-9]{2}-[0-9]+$"
>
>I am not so sure that it really fixes the dash 
>to the 4th position and it definitely would 
>allow more than 6 digits at the end.

Regular expressions might be regular but not 
exactly all the same. For instance PERL has it's 
own schema for regular exxpressions different 
from, say, grep.

The above looks like a PERL expression, but 
probably won't work as expected in grep.

What regular expression tool are you using? Have 
you tried matching w/o the ^ and %?

How about [SACN]\d{1,2}-\d {1,6}
-- 

-dhan

------------------------------------------------------------------------
Dan Shoop                                                   AIM: iWiring
Systems & Networks Architect                      http://www.ustsvs.com/
shoop at iwiring.net                                http://www.iwiring.net/
1-714-363-1174

"The wise man doesn't give the right answers, he poses the right
questions." -- Claude Levi-Strauss

------------------------------------------------------------------------

iWiring provides systems and networks support for Mac OS X, unix, and
Open Source application technologies at affordable rates.


More information about the MacOSX-admin mailing list