Re: Regex help

From: Date: Fri, 28 Jan 2005 22:49:51 +0000
Subject: Re: Regex help
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-207647@lists.php.net to get a copy of this message
kjohnson@zootweb.com wrote: > trlists@clayst.com wrote on 01/28/2005 03:19:14 PM: > >> On 28 Jan 2005 kjohnson@zootweb.com 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. >> >> This is an example of something that is easier to do (and probably >> faster) without using a regexp: >> >> if ((strlen($str) <= $maxlen) && (strstr($str, '&&') === >> FALSE)) >> <str is valid> >> else >> <str is not valid> >> >> -- >> Tom > > Thanks, Tom. I agree, but not an option at this time - other parts of the > design require this to be a regex. Grrrrr. Okay, how about that regex callback thingie thing thing, and you can use a function that pretty much does: (strlen($1) < 42 && !strstr($1, '&&')) -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#207647) next »