XP is just a number | |
PerlMonks |
Re: How do I optimize a regular expression?by moritz (Cardinal) |
on Dec 07, 2009 at 16:29 UTC ( [id://811538]=note: print w/replies, xml ) | Need Help?? |
There are a few things you can try:
(?:thing){0} seems to be a poor man's comment. I'd use an ordinary #...\n comment instead, or (?#...) comments. Second thing: split on whitespaces as far as possible, and then check the individual fields with anchored regexes You can also use (?>...) non-backtracking groups for things that don't have to backtrack. That will make regexes fail faster if they can't match. If you have the choice, use perl 5.10 or newer, it has a an awesome optimization for alternatives of literals.
In Section
Seekers of Perl Wisdom
|
|