Test

Regex Tester

Test regular expressions with live match highlighting

Pattern2 matches
//
Test string
Matches
Contact claude@anthropic.com or support@example.org for help.
#1claude@anthropic.comgroups: ["claude", "anthropic.com"]
#2support@example.orggroups: ["support", "example.org"]

Test JavaScript regular expressions against sample text in real time. See every match highlighted, inspect capture groups, and toggle flags without re-running anything.

Why a live tester beats writing regex blind

Regular expressions are notoriously unforgiving — a misplaced backslash or forgotten anchor can silently change what a pattern matches. Writing them directly into production code and then running the program to see what happens is slow and error-prone. A live tester shortens the feedback loop to zero: you see what matches the moment you type, which makes it realistic to iterate toward the exact pattern you want.

The flags you will actually use

  • g (global) — find all matches, not just the first. This is almost always what you want for search operations.
  • i (case-insensitive) — ignore case. Essential for matching user input.
  • m (multiline) — ^ and $ match line starts/ends, not just the whole string. Useful for log parsing.
  • s (dotall) — . matches newlines as well. Helpful when you want to match across lines.
  • u (unicode) — treat the pattern as a Unicode code point sequence. Required for emoji and astral characters.

Capture groups — the part most people underuse

Any parentheses in your pattern create a capture group. This tool shows every group for every match, letting you extract specific parts of matched text — the username from an email, the path from a URL, the version number from a tag. Named capture groups ((?<name>...)) also work and are often easier to read than numbered ones.

Limitations to know

This tester uses the JavaScript regex engine, which differs from Python, Go, Ruby, PCRE, and .NET flavors in subtle but important ways. Lookbehind assertions, for example, behave differently across engines. If you are writing a pattern for use outside JavaScript, sanity-check it in your target language.

Frequently asked questions

Why does my pattern match nothing when I add the g flag?

When using .exec with the g flag, the regex maintains state (lastIndex) between calls. This tester handles that correctly, but if you see odd behavior it usually means the pattern has a zero-width match, which can cause infinite loops. Adding a character class after an anchor usually fixes it.

How do I match a literal period, slash, or other special character?

Escape it with a backslash: \. \/ \( \) \[ \]. Inside a character class [ ] many of these lose their special meaning and do not need escaping, but it never hurts.

Is this safe for sensitive data like customer records?

Yes — the pattern and test string never leave your browser. Everything evaluates locally using your browser's built-in regex engine.