nwork

Regex Tester

Test and debug regular expressions live. See all matches highlighted, capture groups, and match details instantly as you type.

//
0 matches
Quick reference

How to Use

  1. 1

    Enter your pattern

    Type a regular expression in the pattern field. Toggle flags (g, i, m, s) as needed.

  2. 2

    Enter test text

    Type or paste the text you want to test your regex against.

  3. 3

    Review matches

    Matches are highlighted in color with index positions and capture group values listed below.

How It Works

This tool tests regular expressions live against sample text, highlighting every match, showing capture groups, and displaying match details as you type β€” with a quick reference cheat sheet for common patterns.

Flags and what they change

Global (g) finds all matches instead of stopping at the first one. Case-insensitive (i) ignores letter case when matching. Multiline (m) makes ^ and $ match the start/end of each line rather than just the whole string. Dot-all (s) makes . match newline characters too, which it normally doesn't.

Capture groups

Parentheses in a regex pattern create capture groups β€” portions of the match you can extract separately, like pulling just the area code out of a matched phone number pattern. Each match shown displays its full matched text alongside the value of every capture group within it.

Examples

Validating an email pattern

Testing a pattern like `^[\w.-]+@[\w.-]+\.\w+$` against sample email addresses to check which ones match and which fail, before using that pattern in actual validation code.

Extracting data with capture groups

A pattern like `(\d{3})-(\d{4})` matched against "555-1234" captures "555" and "1234" as two separate groups, useful for pulling structured data out of semi-structured text.

Common Use Cases

  • Debugging and refining a regular expression before using it in actual code
  • Learning regex syntax interactively by testing patterns against real examples
  • Extracting structured data from text using capture groups

Tips

  • Build complex patterns incrementally β€” start with a simple pattern that matches the basic shape you want, then add specificity (anchors, character classes, quantifiers) one piece at a time, testing after each addition rather than writing the whole pattern at once.
  • Remember that JavaScript regex behavior (which this tool uses) can differ subtly from other languages' regex engines (like Python's or PHP's) β€” a pattern tested here should still be re-verified in your actual target language if it's not JavaScript.

Frequently Asked Questions

Related Tools