Skip to content

Regex tester and visualizer

  • Runs on your device
  • Works offline once loaded

Write a regular expression and see matches highlighted as you type. Capture groups are listed, replacements can be previewed, and an explanation breaks the pattern into readable parts. A timeout protects the page from runaway patterns.

How it works

  1. Enter your pattern and flags.
  2. Paste the text to test.
  3. Review the matches, groups and the explanation.

Why use it

  • Live highlighting of matches.
  • Capture groups and named groups.
  • Replacement preview.
  • Timeout guard against catastrophic backtracking.

Testing regular expressions: flags, groups and safe patterns

Write, test and understand

Type a pattern and some test text, and every match is highlighted as you type, with a list of matches and the text each group captured. The Explain tab breaks the pattern into its parts in plain words, which is the quickest way to understand a pattern copied from somewhere else. Examples for common jobs, such as email addresses, URLs, IPv4 addresses, ISO dates, hex colours, UUIDs and phone numbers, give a starting point.

The flags

FlagNameEffect
gglobalFind every match, not only the first
iignore caseA and a are the same
mmultiline^ and $ match at the start and end of every line
sdot all. also matches line breaks
uunicodeTreats emoji and other characters as one; enables \p{L} and friends
vunicode setsLike u, plus set operations inside classes
ystickyMatches only exactly where the last match ended

For text in other languages, use u with Unicode properties: \p{L}+ matches a word in any alphabet, where [a-zA-Z]+ would stop at the first accent.

Groups and replacements

Parentheses capture parts of a match. Name them with (?<year>\d{4}) and refer to them in a replacement as $<year>; numbered groups are $1, $2 and so on, the whole match is $&, and a literal dollar sign is $$. The Replace tab shows the result on your test text, which makes it safe to try a search and replace before running it on real files. For example, (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) with $<day>/$<month>/$<year> turns 2026-10-12 into 12/10/2026.

Patterns that freeze

Some patterns take exponentially longer as the text grows, a problem called catastrophic backtracking. (a+)+$ on a long line of a's followed by one other letter is the classic case: each extra letter doubles the work. In a server, such a pattern can be used to stall it with a single crafted input. The tester runs patterns in a background worker and stops any that run longer than 1.5 seconds, telling you instead of freezing the tab. If that happens, look for nested repetition such as (x+)+ or (x*)* and rewrite it.

Engines differ

This is the JavaScript engine of your browser. Most syntax is shared with Python, Java, PHP and .NET, but not all: lookbehind, possessive quantifiers, named group syntax and Unicode classes vary between them. Test in the language you will use before relying on a pattern in production.

If something goes wrong

  • The pattern shows an error. A bracket or parenthesis is not closed, or a special character needs a backslash, such as \. for a literal dot.
  • Only the first match is found. Switch on the g flag.
  • `^` and `$` match only once. Switch on the m flag to match at every line.

Questions and answers

Which regex flavor is used?

JavaScript, as implemented by your browser.

What if my pattern hangs?

Matching runs in a worker with a 1.5 second limit, so the page stays responsive and you get a warning.

Is my text uploaded?

No.

Esc