How to compare regular expressions in Perl and Python?

The most basic regex features are nearly the same in nearly every implementation: wild character ., quantifiers *, +, and ?, anchors ^ and $, character classes inside [], and back references \1, \2, \3etc.

Alternation is denoted | in Perl and Python

Perl and Python will let you modify a regular expression with (?aimsx). For example, (?i) makes an expression case-insensitive. These modifiers have the same meaning on both languages. Also, both languages let you introduce a comment in a regular expression with (?# … ).

Perl and Python support positive and negative look-around with the same syntax: (?=), (?!), (?<=), and (?<!).

Both languages support the anchors \A and \Z, and the character classes \d and \D, \s and \S.

Both languages let you name a capture with (?P<name>) and reference it with (?P=name). Perl has its own syntax for this in addition to supporting the syntax of Python.