Skip to main content

Python

Describes how recheck checks a regular expression of the python dialect.

Engine​

recheck follows the syntax and the semantics of Python 3.15's re module.

Settings​

  • type is the string type of the pattern and its input, str (default) or bytes.
$ recheck --dialect=python '/^(a|a)*$/'
$ recheck --dialect=python --python-type=bytes '/^(a|a)*$/'

Flags and Units​

The matching unit is code-point for a str pattern (the default type), and byte for a bytes pattern (see Matching Units).

recheck supports the following re flags, written as their letters.

Flagre flagInlineNotes
are.ASCII (re.A)(?a)An error with u or L.
ire.IGNORECASE (re.I)(?i)
Lre.LOCALE (re.L)(?L)Only in a bytes pattern.
mre.MULTILINE (re.M)(?m)
sre.DOTALL (re.S)(?s)
ure.UNICODE (re.U)(?u)The default of a str pattern, and an error in a bytes pattern.
xre.VERBOSE (re.X)(?x)

Syntax Limitations​

\N{...} (e.g. \N{EM DASH}) is reported as unsupported, as in the other dialects having it.

Approximations​

  • L follows the C locale, where 0x80–0xFF follow the ASCII rules, whatever locale the environment has.
  • A conditional on an open group (e.g. (?(1)b|c) in group 1) counts the group as unset when the end of its previous match is before the position where it opens again, and recheck does not reproduce it. For example, ^(?:(a(?(1)b|c))x)+$ matches "acxacx" in Python 3.15, but recheck matches "acxabx" as the other engines do.

Runtime-Attack Verification​

  • Command: python3 -I -.
  • Matching: re.search.
  • Engine limits: none.
  • Engine errors: RecursionError, MemoryError.
  • Environment variable: RECHECK_PYTHON.