JavaScript Regex Tester
Write a pattern, drop in some text, and watch the matches, groups, and replacements update as you type — no run button, no page reload.
How to Use the Regex Tester
Seven steps from a blank pattern field to a checked, working regex.
\d+ or ^hello rather than /\d+/.g) starts checked, so you see every match instead of stopping at the first.What’s in the Tool
Fifteen working parts, in the order you’ll actually reach for them.
Live matching
Matches update as you edit the pattern, flags, or test text. There’s no Run button to hunt for and no page reload — just an immediate answer to “does this actually match?”
Capture groups, every time
Each match lists its numbered groups separately from the full match, so you can see exactly what group 1, group 2, and so on captured — not just whether the overall pattern hit.
Replace preview
The Replace tab applies your replacement string — $1, $&, $<name>, all of it — to your test text and shows the result as you type, before it goes anywhere near your code.
Token-by-token explain
The Explain tab breaks a valid pattern into its pieces — anchors, groups, quantifiers, lookarounds — and describes each one in plain English, not just its official name.
Safety and performance panels
A static heuristic flags nested quantifiers and other backtracking risks before you run into them, next to real execution timing measured by your browser’s own engine.
History, favorites, and a command menu
Recent patterns save themselves, favorites hold onto the ones you reuse across projects, and Ctrl/Cmd+K puts every action a keystroke away.
Built-in cheatsheet
A reference table of character classes, anchors, quantifiers, and group syntax lives further down this page and inside the tool’s Reference tab, so you’re not tab-switching to look something up.
Built for small screens too
The editor, flags, and results panel hold up on a phone as well as a wide monitor, with touch targets sized for fingers and no sideways scrolling.
All seven JS flags
Toggle g, i, m, s, u, v, and y individually. Flags your browser hasn’t shipped yet, like v in older engines, are grayed out instead of failing silently.
Named groups by name
Patterns using (?<name>...) label each result by that name instead of just a position, which keeps a pattern with five or six groups actually readable.
Per-match detail
Beyond the highlighted preview, every match reports its matched text, start and end index, and length, so you’re not counting characters by hand.
Cross-engine compatibility check
Compares your pattern’s syntax against documented support in Python, PCRE2, Java, .NET, PHP, Ruby, RE2, and Rust. It’s a static reference, not eight live engines running in your browser, and it says so plainly.
Test case manager
Save a handful of named test cases with an expected match count, then run them all at once after you tweak a pattern to see what broke.
Working examples
Load a ready-made pattern for email-shaped strings, URLs, dates, hex colors, and more with one click, then bend it to your actual case.
Runs entirely in your browser
Your pattern and test text are matched using the JavaScript engine already loaded on the page. Nothing is sent to a server to compute a result.
Common Regex Examples
Nine patterns worth keeping on hand, each one a practical shortcut rather than a full spec for the format it covers. Click “Load Example” to drop one straight into the tool and start adjusting it.
Regex Flags
A flag changes how a pattern is applied without changing a single character of the pattern itself. JavaScript has seven of them, and every one here behaves exactly as your browser’s engine defines it — nothing custom layered on top.
| Flag | Name | What it does | Example |
|---|---|---|---|
| g | Global | Finds every match instead of stopping after the first one | /\d+/g |
| i | Ignore Case | Matches letters regardless of case | /hello/i matches “Hello” |
| m | Multiline | Makes ^ and $ match the start/end of each line, not just the whole string | /^Line/m |
| s | DotAll | Lets . match line-break characters, which it skips by default | /a.b/s |
| u | Unicode | Treats the pattern as Unicode code points, needed for astral characters and \u{...} escapes | /\u{1F600}/u |
| v | Unicode Sets | An extension of u with set operations inside character classes; newer browsers only | /[\p{L}–[a-z]]/v |
| y | Sticky | Matches only starting at the position of lastIndex, without scanning ahead | /\d/y |
What Is a Regular Expression?
A regular expression, regex or regexp for short, is a pattern that describes the shape of text rather than one exact string. Instead of searching for a literal word, you describe something like “a run of digits,” “anything shaped like an email address,” or “a line starting with a capital letter,” and the engine finds every stretch of your input that fits.
In practice, that shape-matching gets reached for constantly:
- Pulling every number, date, or ID out of a larger block of text
- Checking that a form field roughly matches an expected format, like a username or a hex color
- Extracting structured values out of log lines, URLs, or CSV rows
- Swapping every occurrence of something — a placeholder, a stray character — for something else
- Parsing lightly structured text without reaching for a full parser
None of this looks identical from language to language. Python, PHP, .NET, and JavaScript each ship their own regex engine, and while they share a common ancestor, the details drift apart — lookbehind support, Unicode handling, and even flag names differ. This tool is built specifically around JavaScript’s engine, which the next section covers in more detail.
Regex vs. Plain Text Search
If you only ever need to find one exact string, a plain text search will always be simpler and faster than a regex — searching for "apple" doesn’t call for a pattern language. Regex starts earning its keep once the rule isn’t a fixed string: “apple” or “orange,” any four-digit number, anything sitting inside quotes. A pattern like /apple|orange/gi catches either word in either case in a single pass, where the plain-string equivalent means writing out several separate checks by hand.
Frequently Asked Questions
RegExp engine — the same one your code runs on — so there’s no separate implementation to second-guess.g, i, m, s, u, v, and y. Your browser tells the tool which ones it actually supports, so newer flags like v gray out automatically in older browsers instead of silently doing nothing.$1, $<name>, and $& — against your test text and shows the result live.