Regex Tester – Test JavaScript Regular Expressions

Test regular expressions online with live match highlighting, capture groups and replace preview. Uses JavaScript regex with all flags.

Matches highlighted

How to test a regular expression

  1. Type your pattern without the surrounding slashes, and set flags such as g and i.
  2. Paste the text to search. Matches are highlighted live, and each match's capture groups are listed below.
  3. Optionally type a replacement to preview the result of text.replace().

Regex cheat sheet

.Any character except a line break\d \w \sDigit, word character, whitespace
* + ?0 or more, 1 or more, optional{2,5}Between 2 and 5 times
^ $Start and end of text (or line with m)\bWord boundary
[abc]One of a, b or c[^abc]Anything but a, b or c
(…)Capture group(?<name>…)Named group
a|ba or b(?=…) (?!…)Lookahead, negative lookahead

Frequently asked questions

Which regex flavor does this use?

JavaScript (ECMAScript) regular expressions, exactly as your browser runs them. That's the same syntax used in Node.js, TypeScript and most web tools, and it's very close to PCRE, Python and Java for everyday patterns.

What do the flags do?

g finds all matches instead of just the first. i ignores case. m makes ^ and $ match at line breaks. s lets . match line breaks too. u turns on full Unicode support, and y (sticky) only matches at the exact current position.

How do I use capture groups in the replacement?

Write $1, $2 and so on for numbered groups, $<name> for named groups like (?<name>…), and $& for the whole match. For example, swapping "Doe, Jane" to "Jane Doe" uses the pattern (\w+), (\w+) and the replacement $2 $1.

Is my text sent anywhere?

No. Matching happens in your browser as you type.

Related tools