Re: Regex help

From: Date: Sat, 29 Jan 2005 21:58:34 +0000
Subject: Re: Regex help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-207696@lists.php.net to get a copy of this message
Michael Sims wrote: >> I need a validation regex that will "pass" a string. The string can >> be no longer than some maximum length, and it can contain any >> characters except two consecutive ampersands (&) anywhere in the >> string. >Yup, use this perl regex: > > /^(?:(&)(?!&)|[^&]){1,5}$/ [snip] >Hope this helps you (pass your exam? ;) ) Thanks, Michael! I guess it is time for me to go review those zero-width negative look-ahead assertions - don't know how I missed them ;) And no, not an exam - this is real life. My days as a frolicking schoolboy are quite some distance behind me ;) Kirk

« previous php.general (#207696) next »