Regex Tester & Debugger (JavaScript)
Type a pattern, paste some text and see every match highlighted as you type. Capture groups are listed, replacements are previewed, and common patterns are one click away.
- Free
- No sign-up
- Runs in your browser
Common patterns
Regex cheat sheet
| Pattern | Meaning | Pattern | Meaning |
|---|---|---|---|
| . | Any character except newline | ^ $ | Start / end of text (or line with m) |
| \d \D | Digit / not a digit | \b | Word boundary |
| \w \W | Word character / not | a|b | a or b |
| \s \S | Whitespace / not | [abc] | Any of a, b or c |
| * | 0 or more | [^abc] | Not a, b or c |
| + | 1 or more | [a-z] | Range |
| ? | 0 or 1 (optional) | (abc) | Capture group |
| {3} {3,} {3,5} | Exactly 3 / 3 or more / 3 to 5 | (?:abc) | Group without capturing |
| *? +? | Lazy (as few as possible) | (?<n>abc) | Named group |
| (?=a) | Followed by a | (?!a) | Not followed by a |
| (?<=a) | Preceded by a | (?<!a) | Not preceded by a |
Everything runs in your browser. What you type here is never uploaded, stored or sent anywhere.
What is a regex tester?
A regular expression (regex) is a compact way to describe a pattern in text: "a word, then an @, then a domain". Developers use them to validate form input, search logs, extract data and clean up text. They are powerful, but the syntax is dense and one misplaced character changes everything, so testing a pattern against real examples before you use it is essential.
This tester uses the JavaScript regex engine built into your browser, so what you see is exactly what RegExp will do in your code, in Node.js, or in a Google Tag Manager variable. Matches are highlighted live, each capture group is shown in a table, and the replace tab previews the result of string.replace() with your replacement text.
The pattern runs in a background worker with a time limit. If you accidentally write a pattern that backtracks forever (a famous way to hang a server, known as ReDoS), the tester stops it and tells you, rather than freezing the page. Working with extracted data? Tidy it with the JSON Formatter, or turn it into a table with the CSV Converter.
How to test a regular expression
- Type your pattern between the slashes, or pick a ready-made one such as Email address or PAN card.
- Choose the flags. Use g to find every match, i to ignore upper and lower case, and m so
^and$match at each line. - Paste or type your test text. Matches are highlighted and listed with their position and capture groups.
- Switch to Replace to try a replacement such as
$1 at $2and copy the result. - Happy with it? Click Copy as /pattern/flags and paste it into your code.
What people test with it
- Validating an email address, phone number, PAN, GSTIN or PIN code in a form.
- Pulling IDs, dates or URLs out of a log file or a chunk of text.
- Writing a find-and-replace for a code editor or a bulk text clean-up.
- Checking redirect rules, route patterns or Google Analytics and Search Console filters.
- Learning regex by watching what each change does to the matches.
Frequently asked questions
Which regex flavour does this use?
JavaScript (ECMAScript). It is the same engine used in Chrome, Edge, Firefox and Node.js. Most basics work the same in PHP, Python and Java, but some features differ, such as lookbehind support, possessive quantifiers and named group syntax. Always re-test in your own language.
What do the flags g, i, m, s, u and y do?
g finds all matches instead of just the first. i ignores case. m makes ^ and $ match at line starts and ends. s lets . match newlines. u turns on full Unicode support. y (sticky) matches only at the exact position where the last match ended.
How do I get the text inside brackets, a capture group?
Wrap that part of the pattern in parentheses. In (\w+)@(\w+)\.com, group 1 is the name and group 2 is the domain. They show up in the Groups column, and you can reuse them in a replacement as $1 and $2. Named groups look like (?<name>...) and are used as $<name>.
Why did my regex freeze or get stopped?
Patterns with nested repeats, such as (a+)+$, can take an exponential amount of time on certain input. This is called catastrophic backtracking. The tester stops any run that takes more than about two seconds. Make the inner part more specific, or avoid nesting quantifiers.
Is the Indian mobile number pattern accurate?
It matches 10-digit numbers starting with 6, 7, 8 or 9, with an optional +91 prefix. That is the standard format, but it cannot tell whether a number is actually in use. Use it for format checks, not for verification.
Is my text sent anywhere?
No. Both the pattern and the test text stay in your browser. Nothing is uploaded or stored.
