Re: Regex help
| From: | trlists at clayst dot com | Date: | Fri, 28 Jan 2005 22:19:14 +0000 |
| Subject: | Re: Regex help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-207641@lists.php.net to get a copy of this message | ||
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