An implementation of the Python regex flavor. Technically, this class provides an implementation
for two regex flavors: 'str' regexes, which result from compiling string patterns, and 'bytes'
patterns, which result from compiling binary (byte buffer) patterns.
This implementation supports translating all Python regular expressions to ECMAScript regular
expressions with the exception of the following features:
- case insensitive backreferences: Python regular expressions use a different definition of
case folding and they also allow mixing case sensitive and case insensitive backreferences in the
same regular expression.
- locale-sensitive case folding, word boundary assertions and character classes: When a regular
expression is compiled with the
re.LOCALE flag, some of its elements should depend on the
locale set during matching time. This is not compatible with compiling regular expressions
ahead-of-time into automata.
- conditional backreferences, i.e.
(?(groupId)ifPart|elsePart): These do not have a
direct counterpart in ECMAScript. It should be theoretically feasible to translate Python regular
expressions using these into ECMAScript regular expressions, however the translation would have
to use much more complex global rewriting rules than the current approach.
Furthermore, features not supported by TRegex in general are also not supported (e.g.
backreferences or variable-length lookbehind).