Skip to content
  1. Home
  2. Developer Tools
  3. Regex Tester

Regex Tester — Test Regular Expressions Online

Write a JavaScript regular expression and see matches, capture groups and replacements highlighted live.

Runs 100% in your browser Free, no sign-up Updated

Match preview

Matches & capture groups

No matches yet.

How to use the Regex Tester

  1. Type a pattern without the surrounding slashes and pick flags such as g, i, m or s.
  2. Paste the text to search. Matches are highlighted as you type.
  3. Open the match table to inspect numbered and named capture groups.
  4. Enter a replacement such as $1 or $<name> to preview String.replace().

What is a regular expression?

A regular expression (regex) is a compact pattern language for finding, validating and transforming text. Developers use regexes to validate input formats, parse log lines, extract data from strings, rewrite URLs, and power search-and-replace in editors and build tools. This tester uses your browser’s JavaScript engine, so the results are identical to String.prototype.match, matchAll and replace in Node.js and every modern browser.

Regex cheat sheet

PatternMatches
.Any character except a line break (any character with the s flag)
\d \w \sDigit, word character [A-Za-z0-9_], whitespace
\D \W \SThe opposites of the above
[abc] [^abc] [a-z]One of, none of, a range
^ $ \bStart, end, word boundary
* + ?0 or more, 1 or more, 0 or 1 (greedy)
{3} {2,5} {2,}Exactly 3, 2 to 5, 2 or more
*? +?Lazy versions: match as little as possible
(abc) (?:abc)Capturing group, non-capturing group
(?<name>abc)Named capturing group
a|bEither a or b
(?=x) (?!x)Followed by x, not followed by x (lookahead)
(?<=x) (?<!x)Preceded by x, not preceded by x (lookbehind)
\1 \k<name>Backreference to a group

Avoid catastrophic backtracking

Nested quantifiers such as (a+)+ or (.*)* can make the engine try an exponential number of paths when a match fails, freezing a browser tab or taking down a Node.js server — a class of bug known as ReDoS. This tester runs each match in a background worker and stops it after two seconds. If you hit the limit, make quantifiers more specific ([^,]+ instead of .+) or remove the nesting.

Format checks vs. real validation

A regex can confirm that a string looks like an email address or phone number, but not that the mailbox exists or the number is in service. Use the pattern to reject obvious typos on the client, then confirm the value with a live check such as the Email Verifier or the Phone Number Validator.

Comparing two versions of a file after a regex-based refactor? Use the Code Diff Checker to review every change.

Frequently asked questions

Which regex flavor is used?
The JavaScript (ECMAScript) engine built into your browser, the same one used by Node.js. Most syntax is shared with PCRE, Python and Java, but lookbehind support, named group syntax and some flags differ between engines.
What do the g, i, m, s, u and y flags do?
g finds all matches, i ignores case, m makes ^ and $ match at line breaks, s lets . match newlines, u enables full Unicode, and y matches only at the current position.
How do I reference a capture group in a replacement?
Use $1, $2 and so on for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign.
Why did the tester stop with a timeout?
Some patterns, such as (a+)+$, cause catastrophic backtracking and can take exponential time. Matching runs in a background worker and is stopped after two seconds so the page never freezes.
Can a regex validate an email address or phone number?
Only the format. A regex cannot tell whether a mailbox exists or a phone number is in service. For that you need a live check such as the ProWebLook Email Verification or Phone Validation API.

Last updated . Launched with live highlighting, capture groups, replace preview and timeout protection.

Regex checks the format. ProWebLook checks it is real.

Verify that an email mailbox exists, or that a phone number is valid and reachable, with one API call.

Try the Email Verifier