Regex Tester

Test regular expressions live against your own text, with every match highlighted, capture groups listed, and clear errors when a pattern is invalid.

2 matches found.

Contact us at hello@example.com or support@toolnest.example.org for help.

  • hello@example.com at position 14
  • support@toolnest.example.org at position 35

Test regex patterns against real text, live

A regular expression is only as good as its test data. This tester runs your pattern against text you paste in and shows every match highlighted in place, with its position and capture groups listed below. Change the pattern or the flags and the results update immediately, so you can iterate on a tricky pattern in seconds instead of switching between your editor and a console.

How to use the regex tester

  • Write the pattern without slashes: enter the pattern itself, such as \d+ or [A-Z][a-z]+, and choose flags separately. The tool builds the expression for you.
  • Watch the highlights: each match is marked in your sample text, so you can see at a glance whether the pattern grabs too much, too little, or the wrong part entirely.
  • Check the groups: if your pattern uses parentheses, every group is listed per match. A group that is empty or holds the wrong slice is the most common regex bug, and it shows up here first.
  • Start from a preset: the buttons above load common patterns for email addresses, URLs, phone numbers, dates, hex colors and IP addresses. Use them as-is or edit them to fit your format.

Common regex mistakes this tester catches

  • Greedy quantifiers: .* grabs as much as possible. If your match runs past the closing quote or bracket you expected, try the lazy form .*? and watch the highlight shrink to the right span.
  • Unescaped dots: a plain dot matches any character, so a pattern meant for a file extension like .pdf also matches Xpdf. Escape it as \.pdf when you mean a literal dot.
  • Missing anchors: without ^ and $ a pattern matches anywhere inside the text. That is fine for finding things, but for validation you usually want the whole input to match, which means anchoring both ends.
  • Forgetting the global flag: without g, only the first match is found. If your match count looks too low, check that g is on.

Regex flavors and compatibility

This tester uses JavaScript regular expressions, the flavor built into every browser and into Node.js. Most everyday patterns work identically in Python, PHP, Java and other languages, but a few features differ: lookbehind, named groups and Unicode property escapes are supported in modern JavaScript, while some older or stricter flavors handle them differently. If a pattern must run in another language, test the final version in that language too, and keep an eye on the error message here: it is the same message JavaScript itself reports, so it tells you exactly what is wrong and where.

Frequently asked questions

How do I test a regular expression here?

Type or paste your pattern in the pattern box, pick the flags you need, then paste the text you want to test against. Matches update live: every match is highlighted in the text, listed with its position, and any capture groups are shown underneath. If the pattern is invalid, you get the exact error instead of a silent empty result.

What do the flags mean?

g finds every match instead of stopping at the first. i ignores letter case. m makes ^ and $ match the start and end of each line instead of the whole text. s lets the dot match line breaks. u turns on full Unicode mode, which matters for emoji and characters outside the basic set.

What are capture groups?

Parentheses in a pattern capture part of the match. In (\d{4})-(\d{2})-(\d{2}), group 1 is the year, group 2 the month and group 3 the day. This tool lists the groups for every match, so you can check that each group captures exactly what you intended before using the pattern in code.

Is my test text sent anywhere?

No. The pattern runs in your browser with the built-in JavaScript engine, which is the same engine most websites use. Nothing you type or paste leaves your device, so you can safely test patterns against log lines, private data samples and production-like text.