Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Regex Debugger & Explainer (JavaScript vs Python, ReDoS Check)

Two real engines side by side, every backtracking step, and proof of a ReDoS.

Free preview, no sign-upIncluded in your pass Pro tool Pro pass: ₹179 / $5.99 for 30 days On this device; its files download once
+2 +1 more details No upload Developer

Free preview: the matches in JavaScript and Python with their comparison, the first explained tokens (up to 10), the ReDoS risk and the engine differences. Locked until you unlock it: download and copy.

Pro pass ₹179 for 30 days or ₹79 for 1 week, one‑time. Pro pass $5.99 for 30 days or $2.99 for 1 week, one‑time. How to unlock

Try before you buy.

  • Free preview: the matches in JavaScript and Python with their comparison, the first explained tokens (up to 10), the ReDoS risk and the engine differences.
  • Locked until you unlock it: download and copy.
  • Unlock: Pro pass, ₹179 for 30 days or ₹79 for 1 week, a one-time payment that never renews. Unlock: Pro pass, $5.99 for 30 days or $2.99 for 1 week, a one-time payment that never renews.

Ways to unlock shows how to get the full result.

See passes (opens in a new tab)

Printing this result is locked in the free preview.

Pattern and text

Type it without slashes; the flags are below.

Flags

The first run in Python downloads it (about 13.5 MB) from a separate MySmartCoPilot address; your browser keeps it for later visits. Your pattern and text stay on your device.

Try an example:

Engine 1JavaScript this browser’s RegExp

Type a pattern above.

Engine 2Python CPython’s re module

Press “Compare with Python” to run the same pattern in CPython.

What the pattern says

Where JavaScript and Python read it differently

Catastrophic backtracking (ReDoS)

Checked once the pattern parses.

Railroad diagram

Step debugger

Every attempt and backtrack of JavaScript’s engine on the first match, one step at a time.

Tests

Code

A complete program with your pattern, flags and test text that prints every match. Copy and download unlock with the full result.

Next steps Done. What next?

Start over

A Pro pass unlocks the full result. See passes

All developer tools

About the Regex Debugger & Explainer (JavaScript vs Python, ReDoS Check)

Debug a regular expression in two real engines at once. Your browser’s own JavaScript engine matches as you type, and one press runs the same pattern in CPython’s re module, so you see whether JavaScript and Python agree on your text and, if not, why. A pattern written for one engine runs in the other in that engine’s spelling: (?P<name>…) becomes (?<name>…), \A and \Z are rewritten, comments and verbose spacing are removed, and the page shows the exact pattern each engine ran.

Around the matches the page explains the pattern token by token, lists where the two engines read it differently, and checks it for catastrophic backtracking (ReDoS): nested or overlapping quantifiers are named, and the step debugger counts the steps on growing inputs to prove the slowdown. With the full result you also get a railroad diagram, a step-by-step replay of every attempt and backtrack, tests that must or must not match, and a complete program for JavaScript, Python, PHP, Java, Go, C# or Rust. The free preview shows the matches in both engines and the first lines of the explanation; copying or downloading a program needs a Pro pass or an unlock.

How to use it

  1. Choose the engine you are writing for (JavaScript or Python) and type the pattern without slashes, for example (?<year>\d{4})-(?<month>\d{2}).
  2. Tick the flags you need. The flags shown are the chosen engine’s own: i m s u v y for JavaScript, re.I re.M re.S re.X re.A for Python.
  3. Paste the text to search. JavaScript’s matches are highlighted at once, each with its position and groups; add a replacement to see the replaced text.
  4. Press Compare with Python (or Run in Python). The first run downloads Python once; after that every change re-runs both engines and the Compare line says whether they agree.
  5. Read What the pattern says and Catastrophic backtracking: the preview shows the first lines of the explanation and the ReDoS risk.
  6. With a Pro pass or an unlock, step through the matcher, read the railroad diagram and the ReDoS proof, run your tests, and copy or download the program for your language.

Examples

Find doubled words in Python, and check JavaScript agrees
Input
Written for: Python
Pattern:      \b(?P<word>\w+)\s+(?P=word)\b
Text:         This is is a test of the the finder.
Replacement:  \g<word>
Result
Python finds “is is” and “the the” and replaces them: This is a test of the finder.
JavaScript runs \b(?<word>\w+)\s+\k<word>\b and finds the same two matches.
See why ^(a+)+$ freezes on a long input
Input
Pattern: ^(a+)+$
Text:    aaaaaaaaaaaaaaaaaaaaaaa!
Result
High risk of catastrophic backtracking: (a+)+ repeats a+, which repeats itself.
Proof: 776 steps for 8 a’s, 12,300 for 12, 196,624 for 16, and more than 3,000,000 for 20.

Each extra a roughly doubles the work. Rewrite such a pattern as ^a+$.

Why $ matches in Python but not in JavaScript
Input
Pattern: \d+$
Text:    "Order 42" followed by a newline
Result
JavaScript: no match.
Python: “42”, because its $ also matches just before a newline at the very end of the text.
Unicode digits
Input
Pattern: \d+
Text:    Total: ٤٢ and 42
Result
JavaScript finds only “42”; Python also finds the Arabic-Indic “٤٢”, because its \d matches any Unicode digit.

Common uses

  • Porting a pattern between a JavaScript front end and a Python back end, and proving both accept the same inputs.
  • Reviewing a validation pattern for ReDoS before it reaches production code that handles untrusted input.
  • Understanding a pattern someone else wrote, token by token.
  • Keeping a list of strings that must and must not match next to the pattern, and re-checking them after every change.
  • Getting a ready-to-run program for Java, Go, C#, Rust or PHP, with a warning wherever that engine will not accept the pattern.

Where JavaScript and Python differ

  • \d, \w and \b: ASCII only in JavaScript; any Unicode digit and letter in Python (unless re.ASCII).
  • \s: Unicode spaces in both, but JavaScript’s also matches U+FEFF (the byte order mark) and Python’s also U+001C to U+001F and U+0085.
  • $ without the multiline flag: JavaScript matches only at the very end; Python also just before a final newline.
  • The dot: JavaScript’s refuses \n, \r, U+2028 and U+2029; Python’s refuses only \n.
  • Named groups: (?<name>…) and \k<name> in JavaScript, (?P<name>…) and (?P=name) in Python.
  • Lookbehind: any length in JavaScript; fixed width in Python.
  • Atomic groups (?>…) and possessive quantifiers *+: Python 3.11 and later; not in JavaScript.
  • \p{…} Unicode properties and the v flag’s set operations: JavaScript only (Python’s third-party regex module has properties).

How the ReDoS check works

Both engines are backtracking engines: when a match fails they go back and try every other way to split the text between the quantifiers. A quantifier around something that can itself repeat ((a+)+, (\w+\s?)*), alternatives under a quantifier that can match the same characters ((a|ab)*) and two loops in a row over the same characters (\d+\d+) can make that number of ways grow exponentially or polynomially with the input. A loop inside a repeated group is not flagged when a delimiter it cannot match ends every round ((\d+,)*, (?:-[a-z0-9]+)*), because its text then cannot move into the next round.

The page finds these shapes in the pattern’s tree, then builds an input from the repeated character followed by one that cannot match, and counts the steps the step debugger needs as the input grows: a count that multiplies with each few extra characters is the proof. A shape the count does not confirm on those inputs is called a possible risk, not a high one, since a different input may still be slow.

The programs for other languages

The program for each language holds your pattern in that language’s syntax, your flags and the first 2,000 characters of your test text, and prints every match with its position and groups. Positions count UTF-16 units in JavaScript, Java and C#, code points in Python, and bytes in PHP, Go and Rust. Where an engine will not accept the pattern (Go and Rust have no lookaround or backreferences, .NET no possessive quantifiers, Java needs a bounded lookbehind), or reads it differently ($, \d, \s, the dot), a note under the language says so. The programs were run in each language to check that they compile and find the same matches.

Sources

Limitations

  • Two engines run here: your browser’s JavaScript engine and CPython’s re module. For PHP, Java, Go, C# and Rust the page writes the program and warns what will not compile, but does not run it.
  • The step debugger follows JavaScript’s engine on the first match within the first 5,000 characters (fewer when a loop runs over a very long stretch of text; the page then says how many); it does not model lookbehind, atomic groups, possessive quantifiers, Unicode properties or v-mode sets, and then shows only the real engine’s matches.
  • Python here is the standard re module, not the third-party regex module. Conditional groups such as (?(1)…|…) are not parsed.
  • JavaScript syntax the explainer does not read (duplicate named groups in different alternatives, v-mode \q{…} string literals) still runs in the browser’s engine, but without the explanation, step debugger, ReDoS check, Python comparison and programs.
  • Python runs on the first 50,000 characters of the text and lists up to 1,000 matches; JavaScript lists up to 1,000 matches too.
  • A pattern that runs longer than 3 seconds in JavaScript (15 in Python) is stopped and reported as catastrophic backtracking.

Privacy

On this device; its files download once

Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot. JavaScript matching needs nothing. The first time you run a pattern in Python, Python itself (about 13.5 MB: the CPython interpreter and its standard library, compiled to WebAssembly) is downloaded from a separate, isolated MySmartCoPilot address; your browser keeps it for later visits. Your pattern and text are handed to it inside your browser and never uploaded.

Frequently asked questions

What do I get without a pass?

Without a pass, Regex Debugger & Explainer (JavaScript vs Python, ReDoS Check) shows the matches in JavaScript and Python with their comparison, the first explained tokens (up to 10), the ReDoS risk and the engine differences. Until you unlock it, the result can’t be downloaded or copied. A Pro, Premium or Ultimate pass, a one-time payment that never renews, unlocks the full result. The pricing page lists the passes and their prices.

Is this the real Python regex engine?

Yes. It is CPython’s own re module, compiled to WebAssembly by the Pyodide project, running in an isolated sandbox frame in your browser. The results name the exact Python version.

Why do JavaScript and Python find different matches?

Usually because of $, the dot, or \d, \w and \b, which the two engines define differently. The page lists the differences that apply to your pattern under the explanation, and the Compare line shows the first match where they part.

What does the free preview show?

The matches in both engines with their groups, the comparison, the first lines of the explanation (up to 10), the differences between the engines, the ReDoS risk and the warnings for other languages. The rest of the explanation, the railroad diagram, the step debugger, the ReDoS proof, the test results and the programs, with copy and download, come with a Pro pass or an unlock.

Do my pattern and text leave my device?

No. JavaScript runs in a background worker on this page; Python runs in a sandbox frame inside your browser. Nothing is uploaded.

How is this different from Regex Tester?

Regex Tester is the quick JavaScript tester. This page adds Python’s engine and the comparison, the explanation, the step debugger, the ReDoS proof, tests and programs for seven languages.

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.