Re: OT - Regular Expression
| From: | Roman Neuhauser | Date: | Fri, 09 Feb 2007 12:21:21 +0000 |
| Subject: | Re: OT - Regular Expression | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-248645@lists.php.net to get a copy of this message | ||
# arpad@rajeczy.com / 2007-02-09 12:44:40 +0000:
> 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.
OMG. Sorry, haven't got enough sleep.
> 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.
Yup.
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991