I know that some of the capabilities of the Perl regular expression engine are not regular. However, what class is it? It might be context-free, but CS theory was never my strongest subject.
Perl's regexes are more like the Posix extended ones. Basic posix regular expressions use ( and { to match the actual characters, and \( and \{ as special characters, but the Posix extended ones use ( and { for the same meaning as in Perl and \( or \{ to match the actual characters, the same as Perl.
Python supports essentially the same regular expression syntax as Perl, as far as the regular expressions themselves. However, the syntax for using regular expressions is substantially different.
In general, Perl uses a backtrack regex engine. Such an engine is flexible, easy to implement and very fast on a subset of regex. However, for other types of regex, for example when there is the | operator, it may become very slow.
PHP uses a C library called pcre to provide almost complete support for Perl's arsenal of regular expression features. Perl regular expressions include the POSIX classes and anchors described earlier.
Actually, many implementations are neither regular nor context-free; patterns have become their own beast. This Wikipedia article has more on this, including a bit from Larry Wall, the author of the Perl language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With