Free · No sign-up · Runs in your browser

Regex Tester

Write a regular expression and see matches highlighted live as you type, with capture groups and positions listed. Uses your browser's own JavaScript regex engine, so behaviour is exactly what your code will do.

Test string
2Matches
Highlighted
Contact ada@example.com or alan@test.org for details.
Match details
1ada@example.comat 8
2alan@test.orgat 27

The flags

  • g global — find every match rather than stopping at the first.
  • i ignore case — match regardless of capitalisation.
  • m multiline — makes ^ and $ match at each line start and end rather than only the whole string.
  • s dotall — lets . match newline characters, which it otherwise does not.
  • u unicode — enables proper handling of characters outside the basic plane, including emoji.

Patterns worth knowing

  • \d digit · \w word character · \s whitespace — capitalise any of them to negate.
  • + one or more · * zero or more · ? optional · {2,5} between two and five.
  • ^ start · $ end · \b word boundary.
  • (...) capture group · (?:...) group without capturing · (?<name>...) named group.
  • (?=...) lookahead · (?<=...) lookbehind — assert without consuming characters.

Greedy versus lazy matching

This catches everyone. Quantifiers are greedy by default — they take as much as possible. Against <b>one</b> and <b>two</b>, the pattern <b>.*</b> matches the entire string, because .* grabs everything and only backtracks enough to find the final </b>. Adding ? makes it lazy: <b>.*?</b> stops at the first closing tag and returns two matches instead of one.

Do not parse HTML with regex

Regular expressions cannot correctly parse nested structures — HTML, XML, and JSON included — because they have no concept of arbitrary nesting depth. A pattern that works on your test input will break on real markup with nested tags, attributes containing angle brackets, or comments. Use a real parser. For simply removing tags from text you control, the HTML stripper is the pragmatic option.


Frequently asked questions