Re: Regex help

From: Date: Sat, 29 Jan 2005 02:41:32 +0000
Subject: Re: Regex help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-207659@lists.php.net to get a copy of this message
On Fri, 28 Jan 2005 14:59:29 -0700, <kjohnson@zootweb.com> wrote:
OK, this is off-topic like every other "regex help" post, but I know some of you enjoy these puzzles :) 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. I'm stumped - ideas? TIA Kirk
if(preg_match("/^([^&]|&(?!&)){1,42}$/",$string)) { This one will work I think. Returns false if it finds two consecutive "&" or exceeds 42 chars. -- Stian

« previous php.general (#207659) next »