Free Online Regex Tester & Debugger
Build and debug regular expressions with instant syntax highlighting and capture group breakdowns right inside your browser.
How to Test a Regex
Type your pattern.
Enter the regex between the two slashes, without the slashes themselves. Pick flags with the g, i, m and s buttons, or load one of the three examples.
Paste your test text.
Put sample text in the box below the pattern. Matches highlight as you type, and the count shows how many the pattern found.
Check the groups and copy.
Read the capture groups listed for each match. When the pattern works, copy it as /pattern/flags and paste it into your JavaScript code.
Frequently Asked Questions
Answers about the JavaScript regex engine, flags and groups.
How do I test a regex online?
Type the pattern in the top box without the slashes, then paste sample text below it. Matches highlight as you type and the match count updates. Turn on g to see every match, not just the first one.
Which regex flavor does this tester use?
It uses JavaScript's built-in RegExp engine, the ECMAScript flavor your browser runs. Patterns that match here match the same way in JavaScript and TypeScript code. PCRE, Python and Java syntax can differ, so test those patterns in their own engine.
Why does my regex work in Python or PHP but not here?
JavaScript lacks some PCRE and Python syntax. Possessive quantifiers like a++, atomic groups, the inline (?i) flag and Python's (?P...) named groups fail with Nothing to repeat or Invalid group. A \K is read as a plain K. Rewrite those parts in JavaScript syntax.
What do the g, i, m and s flags do?
The g flag finds every match instead of stopping at the first. The i flag ignores upper and lower case. With m, the ^ and $ anchors match at each line. With s, the dot also matches line breaks. Only g starts on.
Does it support the u, y or d flags?
No. Only g, i, m and s can be turned on. Without u, Unicode property escapes don't work and an emoji counts as two characters, so a dot matches half of it. Test Unicode-heavy patterns in your own code for now.
How do I use named capture groups?
Put a question mark and a name in angle brackets right after the opening parenthesis, as in the built-in word example. Each match then lists the group by name, like word: longer. If a pattern mixes named and unnamed groups, only the named ones are listed.
Why does my pattern show empty matches?
Patterns that can match nothing, like a* or \d*, also match an empty string at each spot that doesn't fit. On the text bbb, a* gives 4 empty matches. Use + instead of * when you need at least one character.
Why does ^ only match the first line?
Without the m flag, ^ and $ mark the start and end of the whole text. Turn on m and they match at every line break, so a pattern like ^\w+ finds the first word of each line instead of only the first line.
Why does the page freeze on some patterns?
Nested quantifiers like (a+)+$ cause catastrophic backtracking, and the tester has no time limit. In a Node test of the same code, 27 letters took about 2 seconds and each extra letter doubled it. Narrow the inner group, and reload the tab if it locks.
Can I replace text with this regex tester?
No, there is no replace mode yet. The tester shows matches and capture groups only. To plan a replace, check that each group captures the right part, then use it as $1 in String.replace in your own code.
Is the text I test sent anywhere?
The test text is not sent; matching runs in your browser. On the live site, Google Analytics notes each match run and its time. For an invalid pattern it also gets the error message, which in Chrome includes the pattern itself.
Regex Tester Features for JavaScript Patterns
Your pattern runs on the browser's own JavaScript RegExp engine, so a pattern that matches here matches the same way in your JS code.

Highlight Regex Matches as You Type
Every match in your test text is marked in color, and the match count above it updates on each change. With g on you see all matches; with it off, only the first.
- Recomputes on every keystroke
- The g flag finds every match
- Match count shown above the text

See Capture Groups for Each Match
Below the highlights, each match gets its own line with its groups. Named groups show by name, like word: longer, and unnamed groups show as Group 1, Group 2 and so on.
- Named groups listed by name
- Groups that matched nothing show a dash
- One line per match
Four Flags, One Click Each
Buttons next to the pattern switch global (g), ignore case (i), multiline (m) and dotAll (s). The g flag starts on. There is no u, y or d flag yet.
See Why a Pattern Fails
An invalid pattern shows the engine's own message, such as Unterminated group or Nothing to repeat, in a red box. Fix the pattern and the matches come back.
Start From an Example
Three sample patterns load with one click: email addresses, ISO dates such as 2024-01-15, and a named group for words of five letters or more. Copy puts the pattern on your clipboard as /pattern/flags.
Your Test Text Stays Here
Matching runs on your device and the text you test is never sent. Usage stats note how long a match took and, for an invalid pattern, the error message, which can include the pattern.
Common Regex Use Cases
Three everyday jobs where testing a regex first saves a bug later.
Form Validation
Check an email, phone or postcode pattern against real samples before it goes into a form. Paste good and bad inputs on separate lines and see which ones match.
- Paste valid and invalid inputs, one per line
- Turn on m so anchors match each line
- Confirm the pattern rejects every bad sample
Log Parsing
Pull fields out of log lines, like IP addresses, timestamps and status codes. Paste a few lines from a log file and use groups to capture each part.
- Capture IP addresses with numbered groups
- Match ISO dates such as 2024-01-15
- Name each group so every field is labeled
Text Search Before a Replace
Find every URL, hashtag or repeated word in a block of text before you write the replace step in your code. The match count tells you how many hits to expect.
- Find URLs and email addresses in pasted text
- Spot doubled letters or words with a backreference
- Check the match count before a bulk replace
Explore More Tools
Discover other free tools that work great alongside this one
Diff Checker
Compare two texts side by side
JSON Formatter
Format, validate and minify JSON in your browser
URL Encoder
Encode and decode URL components
Markdown to HTML
Convert Markdown to HTML with a live preview
Base64 Encoder
Encode and decode Base64 strings
Hash Generator
Generate SHA-1, SHA-256 and SHA-512 hashes of text or files