Regex Tester

Test regular expressions with live highlighting, match info, and replace mode.

//g

Common Patterns

What Is the Regex Tester?

The Regex Tester is an online tool for writing, testing, and debugging regular expressions in real time. Type a pattern and a test string, and the tool instantly highlights all matches, shows match details including capture groups, and lets you test find-and-replace operations.

This tool uses the JavaScript regular expression engine, so your patterns behave exactly as they would in JavaScript, TypeScript, or Node.js code. It is ideal for developers building validation rules, parsing logic, or text transformations.

How to Use the Regex Tester

  • Enter your regular expression pattern in the Pattern field. The tool wraps it in forward slashes automatically.
  • Toggle flags using the checkboxes: g (global), i (case-insensitive), m (multiline), s (dotAll), and u (unicode).
  • Paste or type your test string in the text area below. Matches are highlighted instantly in the Highlighted Matches section.
  • Scroll down to see a numbered list of every match, its position in the string, and any captured groups.
  • Click Show Replace Mode to enter a replacement pattern. The tool shows the result of applying your regex replacement to the entire test string.
  • Use the Common Patterns sidebar to load pre-built patterns for emails, URLs, phone numbers, IP addresses, dates, and hex colors.

Understanding Regex Flags

The global flag (g) finds all matches instead of stopping at the first one. Case-insensitive (i) ignores letter casing. Multiline (m) makes ^ and $ match line boundaries. DotAll (s) makes the dot character match newlines. Unicode (u) enables full Unicode matching for characters outside the basic Latin set.

Tips for Writing Better Regular Expressions

  • Start with a simple pattern and refine it incrementally while watching the matches update
  • Use capture groups with parentheses to extract specific parts of a match
  • Test edge cases by including unusual input in your test string
  • Use the replace mode to verify that your regex-based transformations produce correct output
  • Check the error message area if your pattern is invalid, as it shows the exact JavaScript error

Common Use Cases

  • Validating email addresses, URLs, or phone numbers in form input
  • Extracting data from log files or structured text
  • Building search-and-replace operations for code refactoring
  • Learning regular expression syntax with instant visual feedback

Frequently Asked Questions

How do I test a regex pattern online?+
Enter your pattern in the Pattern field and paste your test text below it. The tool highlights all matches in real time and shows detailed match information including index positions and capture groups.
What regex engine does this tester use?+
This tool uses the native JavaScript RegExp engine. Patterns behave identically to how they run in JavaScript, TypeScript, and Node.js, making it ideal for web development testing.
How do I use capture groups in regex?+
Wrap part of your pattern in parentheses to create a capture group. For example, (\d{4})-(\d{2}) captures a year and month separately. The tool displays captured groups for each match below the highlighted results.
Can I do regex find and replace with this tool?+
Yes. Click Show Replace Mode, enter your replacement pattern using $1, $2 for group references, and the tool shows the replaced output in real time. You can copy the result with one click.
What does the global flag (g) do in regex?+
The global flag tells the regex engine to find all matches in the string instead of stopping after the first one. Without it, only the first match is returned.
How do I match an email address with regex?+
Click the Email button in the Common Patterns sidebar to load a standard email-matching pattern. You can then modify it to fit your specific validation needs and test it against sample email addresses.

Related Tools

Regex Tester — free online regex tester, regex tester online, regular expression tester, test regex pattern, regex match highlighter, regex replace tool, JavaScript regex tester. No signup required. Works in your browser.