Next | Regular Expression Mastery | 79 |
Common cases are heavily optimized
/literal/ doesn't use the regex engine
Instead, it does a Boyer-Moore search
/^PAT/ never advances the cursor
/PAT$/ starts at the correct place if the length of the result is known
If the target string is too short, the regex engine is never invoked
/(fish|dog){7,12}\s+/ cannot match any string shorter than 22 characters
When in doubt, benchmark!
-Mre=debug is helpful here also
The /i modifier makes the match case-insensitive
It tends to disable optimizations
Use it sparingly
Next | Copyright © 2002 M. J. Dominus |