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
typeis the string type of the pattern and its input,str(default) orbytes.
- CLI
- JavaScript
- Scala
$ recheck --dialect=python '/^(a|a)*$/'
$ recheck --dialect=python --python-type=bytes '/^(a|a)*$/'
import { check } from "recheck";
await check("^(a|a)*$", "", { dialect: "python" });
await check("^(a|a)*$", "", { dialect: { name: "python", type: "bytes" } });
import codes.quine.labs.recheck.ReDoS
import codes.quine.labs.recheck.common.Parameters
import codes.quine.labs.resyntax.dialect.Dialect
ReDoS.check("^(a|a)*$", "", Parameters(dialect = Dialect.Python()))
ReDoS.check("^(a|a)*$", "", Parameters(dialect = Dialect.Python(Dialect.Python.Type.Bytes)))
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.
| Flag | re flag | Inline | Notes |
|---|---|---|---|
a | re.ASCII (re.A) | (?a) | An error with u or L. |
i | re.IGNORECASE (re.I) | (?i) | |
L | re.LOCALE (re.L) | (?L) | Only in a bytes pattern. |
m | re.MULTILINE (re.M) | (?m) | |
s | re.DOTALL (re.S) | (?s) | |
u | re.UNICODE (re.U) | (?u) | The default of a str pattern, and an error in a bytes pattern. |
x | re.VERBOSE (re.X) | (?x) |
Syntax Limitations
\N{...} (e.g. \N{EM DASH}) is reported as unsupported, as in the other dialects having it.
Approximations
Lfollows the C locale, where0x80–0xFFfollow 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, andrecheckdoes not reproduce it. For example,^(?:(a(?(1)b|c))x)+$matches"acxacx"in Python 3.15, butrecheckmatches"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.