in reply to Re: Regular Expression Question
in thread Regular Expression Question
you should test your regexp on ",foo," which will work, and shouldn't, as will "!!foo!!,".
So for a working single regexp you want (assuming \w is good enough)...
/^\w+ # Starts with a "word" (?:,\w+)*$/x; # Followed by many "comma and word" atoms
Which IMO is ugglier than...
/^[\w,]+$]/ && # Comma word atoms ! /^,|,,|,$/; # With constraints on commas
It's probably faster to use 2 regexps too
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Regular Expression Question
by simonm (Vicar) on Dec 04, 2003 at 20:59 UTC | |
by nevyn (Monk) on Dec 04, 2003 at 21:45 UTC | |
by Abigail-II (Bishop) on Dec 05, 2003 at 15:09 UTC | |
by simonm (Vicar) on Dec 05, 2003 at 21:56 UTC |