So my copy of the classic book, Mastering Regular Expressions, just arrived, and I'm scanning through it. The cover (third edition) says, "for Perl, PHP, Java, .NET, Ruby, and More!" Well, it does have a full chapter for each of Perl, PHP, Java, and .NET - but no chapter on Ruby, or, more importantly to me, on Python.
Although the index lists a few points of Python's differences (such as how it handles newlines), there's not even a table of them, much less an entire chapter.
Which of the four covered languages, is Python's regex engine most similar to? More importantly, how similar, and what are the major differences?
Note - I don't mean how regexes are used in Python (versus, say Perl) - I know and use the re
module. I'm only interested in the syntax differences of the actual regexes.
re
module claims it is similar to Perl's regular expression functionality, but as tchrist explains in this pretty extensive answer over at SO (answer here), the defaultre
module is deficient in key areas like Unicode matching, and one should use the currently 3rd partyregex
module instead, if possible, as it has better functionality and Perl-compatibility. Ruby is also Perl-inspired, but also lacks a lot of functionality for things like Unicode.