On Wed, Mar 23, 2005 at 04:05:56PM -0800, Lan Barnes wrote: > On Wed, Mar 23, 2005 at 05:57:20PM -0600, Gabriel Sechan wrote: > > > > > > >From: Brian Deacon <[EMAIL PROTECTED]> > > > > > >^((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.
I got weirdness when I used \s instead of ( ). It was matching across lines. Although this is just being used to validate web input... so multilines isn't an issue... Maybe I just needed to put the \s inside (). <shrug> The bigger problem is the repeating of "crazy". What would be the coolest would be if regex would let me variablize the "crazy" regex and then let me refer to it later. Hmmm... B -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list
