Skip to content
M2TOOLKIT

Developer · free tool

Regex Tester

Test regular expressions against sample text with live highlighting and capture groups.

Use it as often as you like — it's free, with no sign-up and no limits.

  • Developer
  • Free
  • No sign-up
  • Runs in your browser
  • Updated
/
/gi

Highlighted

Enter a pattern to test.

Matches and groups

No matches yet.
Regex cheat sheet
.any character except newline
\d \w \sdigit, word character, whitespace
\D \W \Snot digit / word / whitespace
[abc] [^abc]one of / none of a, b, c
a* a+ a?0+, 1+, 0 or 1 of a
a{3} a{2,5}exactly 3 / between 2 and 5
^ $start / end of string (or line with m)
\bword boundary
(abc) (?:abc)capture group / non-capturing group
(?<name>abc)named group
a|ba or b
(?=a) (?!a)followed by / not followed by a

Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us.

How to use the Regex Tester

  1. Type your pattern (without slashes).
  2. Tick the flags you need.
  3. Paste test text and see matches highlighted.
  4. Check each match's groups on the right.

What does this tool do?

The tester uses JavaScript's regular expression engine, so results match what you'll get in browsers and Node.js. It shows every match with its position, numbered groups and named groups.

Patterns run in a separate background worker with a time limit. If a pattern triggers catastrophic backtracking, it's stopped instead of freezing your browser.

Why use it?

  • Build and debug patterns quickly.
  • See groups for search-and-replace.
  • Safe against runaway patterns.

Use cases

  • Check a validation pattern (email, postcode, order number) against real examples before shipping it.
  • Work out capture groups for a search-and-replace in your editor or code.
  • Debug why a pattern matches too much or too little.

Example

Pattern (\w+)@(\w+)\.com with flags gi on “ada@example.com” matches the whole address, with “ada” as group 1 and “example” as group 2.

Common mistakes

  • Forgetting the g flag and wondering why only the first match is found.
  • Using . to mean a literal dot — escape it as \. (for example \.com).
  • Greedy quantifiers: <.+> matches from the first < to the last > on the line; <.+?> stops at the first >.

Accuracy and limits

  • Other languages' regex engines (PCRE, Python, Java) are similar but not identical — for example in lookbehind and Unicode support.

Privacy

Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.

Frequently asked questions

Can I test Python, Java or C# regex here?

The engine is JavaScript's, so most everyday patterns behave the same in Python, Java, C# and PCRE. Differences show up in features such as possessive quantifiers, atomic groups, inline flags like (?i) and some Unicode classes — check those in your target language.

Do I type the slashes?

No. Type only the pattern and tick the flags; the tester shows the full /pattern/flags form for you.

Why did my pattern stop with a timeout?

Some patterns, like (a+)+$, take exponential time on certain inputs (catastrophic backtracking). The tester runs patterns in a background worker with a time limit so your browser doesn't freeze, and stops them.

What do the g, i and m flags do?

g finds all matches instead of stopping at the first, i ignores upper and lower case, and m makes ^ and $ match at the start and end of every line rather than the whole text.

Last reviewed by the M2Toolkit team.

Other tools people use alongside the regex tester.