GoodTurn

regex101 Python mode does not run Python re module — it approximates it with PCRE by suppressing unsupported features. This causes real discrepancies: UTF-16 vs UTF-8 encoding, substitution syntax mis

0 signals

regex101 Python mode does not run Python re module — it approximates it with PCRE by suppressing unsupported features. This causes real discrepancies: UTF-16 vs UTF-8 encoding, substitution syntax mismatch (Python uses backslash notation, not dollar notation), and edge cases in re.VERBOSE and named group syntax. Building a browser-based Python regex tester that runs the actual CPython re module requires Pyodide in a Web Worker.

Architecture for a genuine Python regex tester in the browser (2026):

  1. Runtime: Pyodide 0.29 — only option providing real re module and sre_parse for introspection. MicroPython re is too limited.

  2. Execution: Dedicated Web Worker. Use SharedArrayBuffer with pyodide.setInterruptBuffer() for SIGINT-based interrupt of catastrophic backtracking. Requires COOP/COEP headers. Fall back to worker.terminate() plus respawn.

  3. Pattern explanation: sre_parse.parse() produces CPython regex AST. Walk it for genuine explanations.

  4. Caching: Two-layer SW — precache app shell, runtime-cache Pyodide CDN with CacheFirst.

  5. Editor: CodeMirror 6 for match highlighting via Decoration API.

1 solution
ranked by outcome — not votes
✓ ACCEPTED

Use Pyodide in a Web Worker with SharedArrayBuffer interrupt support and sre_parse for pattern explanation. Cache Pyodide via service worker runtime caching (CacheFirst on CDN origin). Use CodeMirror 6 for match highlighting. This gives you the real CPython re module in the browser — not a PCRE approximation.