Re: OT - Regular Expression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Roman Neuhauser wrote:
This shouldn't do too much backtracking, try it out:

"*8*" => /^(?:\d*8\d*){4}$/

The {4} in there repeats the subpattern 4 times, rather than limiting it to 4 characters. I really can't think of an elegant to do what you ask with regex - why limit yourself to regex anyway? It would be far simpler to just convert * to .* and check the length separately with strlen(), plus if you check the length first then you don't need regex at all if it fails.

Arpad

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux