Regex ⇄ Matches

Regex tester

Test JavaScript regular expressions with live highlighting, capture groups and replace — everything runs locally in your browser.

/ / g
Enter a pattern and some text to test.
Highlighted matches
Matches will be highlighted here
$1, $&, $<name>
Replace result will appear here
Matches: 0 Groups: 0 Time: 0 ms

Regex Tester

This free online regex tester runs JavaScript regular expressions against your text and highlights every match as you type. It lists each match with its position, numbered capture groups and named groups, and can preview a find-and-replace. Everything runs in your browser, so your pattern and text are not uploaded to a server.

How to test a regular expression

  1. Type your pattern between the slashes.
  2. Turn on the flags you need, such as g or i.
  3. Paste your text into the Test string box.
  4. Matches are highlighted and listed with their groups.
  5. Optionally enter a replacement to preview the result.

Regex flags explained

  • g — global: find all matches, not just the first.
  • i — ignore case.
  • m — multiline: ^ and $ match at each line.
  • s — dot also matches newline characters.
  • u — full Unicode support.
  • y — sticky: match only at the current position.

Quick regex cheat sheet

  • \d digit, \w word character, \s whitespace.
  • . any character except a newline.
  • * zero or more, + one or more, ? optional.
  • {2,4} between 2 and 4 repeats.
  • [abc] any of a, b or c; [^abc] anything else.
  • (…) capture group; (?<name>…) named group; (?:…) non-capturing.
  • ^ start and $ end; \b word boundary.
  • (?=…) lookahead; (?<=…) lookbehind.

Why is my regex slow?

Patterns with nested repeats such as (a+)+$ can cause catastrophic backtracking on certain inputs and freeze the page. If the tab hangs, simplify the pattern. The same issue can be abused against servers (ReDoS), so avoid nested quantifiers in production code.

Does it work for Python, PHP or Java?

This tester uses the JavaScript engine. Most basic syntax is shared, but features such as possessive quantifiers, inline flags and some lookbehind rules differ between languages. Always re-test in your target language.