Need some regex help
Lan Barnes
lan at falleagle.net
Wed Mar 23 16:05:56 PST 2005
On Wed, Mar 23, 2005 at 05:57:20PM -0600, Gabriel Sechan wrote:
>
>
> >From: Brian Deacon <brian at navelplace.com>
> >
> >^((crazy)( )*[;\,]( )*)*(crazy)( )*[;\,]?$
> >
> >Gack... even that version looks gnarly...
> >
> >Anywho... the idea is to verify that the input is a string of either
> >comma or semi-colon delimited instances of "crazy". Any amount of
> >spaces surrounding the delimiters. The catch is that I don't want to
> >require that the input end in a delimiter, so that any of these would
> >be valid:
> >crazy
> >crazy, crazy
> >crazy,crazy,crazy
> >crazy,crazy;crazy;
> >
> Wouldn't
>
> (\w*crazy\w*)([\,;](\w*crazy\w*))*
>
> do this? (\w*crazy\w*) should be crazy followed by any amount of white
> space. [\,;]\w*crazy\w* should be crazy preceeded by a , or ; with any
> amount of whitespace. By *ibng that part, you can have any number of
> additional crazies. Actually on relook, I think I got almost the same
> thing except I used \w for whitespace, which seems like a better choice
> than ( ) and I put the optional crazies on the end, not the begining.
>
Um ... \w means word char [A-Za-z0-0etc] and \s means white space.
> >And the above works fine for that. The problem is that I'm not actually
> >looking for the word "crazy", I'm looking for valid smtp email
> >addresses. I stole a >500 character long regex from regexlib.com
> >Umm... this one:
> >http://www.regexlib.com/REDetails.aspx?regexp_id=328
> >
> Thats because SMTP is absolutely insane in the number of legal options for
> an email address (an IP is a legal address for some reason). If you need
> to work with anything, you need something complex.
>
> Gabe
>
>
> --
> KPLUG-List at kernel-panic.org
> http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list
--
Lan Barnes lan at falleagle.net
Linux Guy, SCM Specialist 858-354-0616
More information about the KPLUG-List
mailing list