Skip to content
codinganthem
All tools/Text Utils/Regex Tester

Regex Tester

Test and debug regular expressions online with live match highlighting. See match counts and positions instantly — free, no console needed.

//
1 of 2
Contact alice@example.com or bob@test.org for details.

Tip: press [ / ] to jump between matches

How to test a regular expression

Type a pattern, add flags, and paste text to search. Matches are highlighted as you type, the match count updates, and capture groups are listed for each match. Use Prev and Next, or the [ and ] keys, to step through matches in long text. Patterns run on your browser's JavaScript regex engine, so results match what new RegExp() does in your code.

Cheat sheet

  • . any character except a newline · \d digit · \w letter, digit or underscore · \s whitespace
  • [abc] one of a, b or c · [^abc] anything else · [a-z] a range
  • ^ start · $ end (of each line with the m flag) · \b word boundary
  • * 0 or more · + 1 or more · ? 0 or 1 · {2,4} between 2 and 4
  • (...) capture group · (?:...) group without capturing · (?<name>...) named group · a|b either
  • Flags: g find all matches, i ignore case, m multiline, s let . match newlines, u Unicode

Greedy vs lazy

Quantifiers are greedy: they match as much as they can. On the text <a><b>, the pattern <.+> matches the whole string. Add ? to make it lazy: <.+?> matches <a> and then <b>.

Patterns people search for

Simple email check:   ^[^\s@]+@[^\s@]+\.[^\s@]+$
ISO date:             ^\d{4}-\d{2}-\d{2}$
Hex colour:           ^#(?:[0-9a-fA-F]{3}){1,2}$
Whole word "error":    \berror\b

The email pattern catches obvious typos but doesn't follow the full email standard; the only real check is sending a confirmation email.

Avoid catastrophic backtracking

Nested quantifiers like (a+)+$ can take exponential time on text that almost matches, freezing a browser tab or a server. Prefer specific character classes over .*, and avoid repeating a group that itself repeats.

Frequently asked questions

Which regex flavour does this tester use?+

Your browser's JavaScript engine, the same as new RegExp() in JavaScript and Node.js. Most syntax is shared with PCRE, Python and Java, but some features differ, such as possessive quantifiers.

Why does my regex match only once?+

Without the g (global) flag, a JavaScript regex stops at the first match. Add g to find every match.

How do I match across multiple lines?+

Use the m flag so ^ and $ match at each line, and the s flag so . also matches newline characters.

What does a lazy quantifier do?+

Adding ? after *, + or {n,m} makes it match as little as possible. For example <.+?> matches each tag separately instead of everything from the first < to the last >.