Two engines that look alike
JavaScript and Python regular expressions share most of their syntax and differ in the details that bite: how named groups are written, what \d and \w match, where $ stops, and features one has and the other lacks. This tester runs the real engines — your browser's for JavaScript and CPython's re module for Python — so a pattern that works here works in your code. Compare Both runs them side by side and shows where they disagree.
Regex cheat sheet
| Syntax | Meaning | JavaScript | Python |
|---|---|---|---|
| . | Any character except a newline | With s, newlines too | With DOTALL, newlines too |
| \d \w | Digit, word character | ASCII only | Any Unicode digit or letter; ASCII with re.ASCII |
| \s \b | Whitespace, word boundary | Same in both | |
| ^ $ | Start and end — of each line with m / MULTILINE | $ is the very end | $ also matches before a final newline; \Z is the very end |
| * + ? {2,5} | Repeat; add ? to make it lazy | Same in both | |
| (…) (?:…) | Capturing and non-capturing group | Same in both | |
| Named group | A group you can refer to by name | (?<name>…), \k<name> | (?P<name>…), (?P=name) |
| (?=…) (?!…) | Lookahead | Same in both | |
| (?<=…) (?<!…) | Lookbehind | Any length | Fixed width only |
| (?>…) a*+ | Atomic group, possessive quantifier | Not supported | Python 3.11+ |
| Replacement | Refer to a group in the replacement | $1, $<name>, $& | \1, \g<name>, \g<0> |
How to use the regex tester
- Pick JavaScript or Python. Python loads its runtime the first time, which takes a few seconds.
- Type the pattern and toggle flags. Matches highlight in the text as you type; groups and their positions are listed on the right.
- Click a match in the list to select it in the text.
- Tick Replace With to preview a substitution, using the flavour's own group syntax.
- Press Copy Code for a ready-to-paste snippet with the pattern, flags and replacement filled in.
Examples
Parse log lines with named groups
Level, time and message as named groups, one match per line.
Reformat dates with a replacement
31/12/2026 to 2026-12-31 with three groups.
See where JavaScript and Python disagree
\d matches Arabic-Indic digits in Python but not in JavaScript.
Survive a runaway pattern
^(a+)+$ on a near-miss takes forever. The tester stops it instead of freezing.
Frequently asked questions
Why does my pattern work here but not in my code?
Usually the string literal, not the regex. In Python, write patterns as raw strings — r"\d+" — or every backslash has to be doubled. In JavaScript, a pattern built with new RegExp("…") needs doubled backslashes too; a /…/ literal does not. Copy Code gets this right for you.
Why did the tester stop with "took too long"?
Some patterns, like (a+)+, try exponentially many ways to match before giving up — catastrophic backtracking. In a server, one such input can tie up a process. Rewrite the pattern so no two parts can match the same text, or use an atomic group in Python 3.11+.
Why does \d match digits that are not 0–9 in Python?
In Python, \d on a str pattern matches any Unicode decimal digit, including Arabic-Indic and Devanagari ones. Use [0-9] or the ASCII flag when you mean only 0–9. In JavaScript, \d is always 0–9.
How do I match across several lines?
Two flags do different things. m / MULTILINE makes ^ and $ match at every line. s / DOTALL lets . match a newline, so .* can run past the end of a line.
Is my text sent anywhere?
No. Both engines run in your browser. Choosing Python downloads the Python runtime from jsDelivr once; nothing you type is sent.