Avoiding Perl Regular Expressions

Although regular expressions are a complex but extremely useful tool for the analysis of strings, they are based on fuzzy logic and, therefore, have high computational demands. Although there can be no universal statement, some rules of thumb can be compiled to support a case-to-case decision whether simple string analysis based on index(), substr(), chr() and ord() is able to improve the time complexity of a perl script with respect to regular expressions.

While the mentioned internal functions must be glued into a parser to be of any use, they need to be interpreted by perl while regular expressions are executed as native code apart from the interpreter.

See also: Documenting Regular Expressions and performance considerations

Feedback is always welcome! If you'd like to get in touch with me concerning the contents of this article, please use Twitter.