PureKit

Regex Tester

Test and debug regular expressions with live matching

100% Client-Side • Privacy Protected
//g

Features

  • Real-time regex matching with instant visual feedback
  • Support for all JavaScript regex flags (g, i, m, s, u, d)
  • View capture groups and named groups for each match
  • Test replacement patterns with $1, $2 syntax
  • All processing in browser — your test data stays private

How to Use the Regex Tester

  1. 1Enter your regular expression pattern in the pattern field
  2. 2Select regex flags (g for global, i for case-insensitive, etc.)
  3. 3Type or paste your test string in the text area
  4. 4View matches highlighted in real-time with capture group details

Frequently Asked Questions

Which regex flavor does this use?

This tool uses JavaScript's built-in RegExp engine, which supports ECMAScript regex syntax. This includes features like lookbehind assertions, named capture groups, Unicode property escapes, and the dotAll (s) flag.

Can I use replacement patterns?

Yes. Enter a replacement pattern using $1, $2 for capture group references, $& for the full match, $` for text before the match, and $' for text after. Named groups can be referenced with $<name>.

How do I match across multiple lines?

Use the 'm' (multiline) flag to make ^ and $ match the start and end of each line. Use the 's' (dotAll) flag to make '.' match newline characters as well.

What are capture groups?

Capture groups use parentheses () to extract parts of a match. For example, (\d{4})-(\d{2}) captures a year in $1 and a month in $2. Use (?:...) for non-capturing groups when you need grouping without extraction. Named groups like (?<year>\d{4}) let you reference matches by name.

How do I write a regex for email validation?

A practical basic pattern is: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ — this covers most real-world email addresses. Keep in mind that the full email RFC is extremely complex, so for production systems it's best to combine a simple regex check with actual email verification (sending a confirmation link).

What is the difference between .* and .*? (greedy vs lazy)?

.* is greedy — it matches as much text as possible. .*? is lazy (or non-greedy) — it matches as little as possible. For example, given '<b>hello</b><b>world</b>', the pattern <b>(.*)</b> greedily captures 'hello</b><b>world', while <b>(.*?)</b> lazily captures just 'hello'. Use lazy quantifiers when you want the shortest match.

Related Tools