What Is This Tool?
A regular expression (regex) is a compact pattern language for finding, validating and extracting text: an email pattern can validate form input, \d{4}-\d{2}-\d{2} finds dates, and capture groups pull out the parts you need. Nearly every programming language and editor supports regex.
This tester uses the JavaScript regex engine — the same one that runs in Node.js and every browser — so patterns you build here behave identically in your JavaScript/TypeScript code. Most patterns also work unchanged in Python, Java and Go.
Why Use It?
- Live feedback: matches highlight in yellow as you type the pattern.
- Capture groups shown per match — see exactly what $1 and $2 will contain.
- Full flag support: g (all matches), i (ignore case), m (multiline), s (dot matches newline), u (unicode).
- Clear error messages when the pattern has a syntax mistake.
- Free and private — pattern and text never leave your browser.
How to Use
- Type your pattern between the two / characters (no need to escape slashes yourself).
- Adjust flags in the small box after the second / — the default g finds all matches.
- Paste your test text below.
- Matches highlight instantly; capture groups are listed underneath.
- If the pattern is invalid, the error message explains what's wrong.
Example
Input
Pattern: (\w+)@(\w+)\.com
Test string: Contact alice@example.com or bob@test.comOutput
✓ 2 matches
#1 groups: $1=alice $2=example
#2 groups: $1=bob $2=testThe parentheses create capture groups you can reference as $1 and $2 in replacements.
Practical tips
- Validating an email input? ^[^\s@]+@[^\s@]+\.[^\s@]+$ is a permissive pattern that catches obvious typos without rejecting valid-but-unusual addresses — full RFC 5322 compliance needs a library, not a one-liner.
- Extracting query params from a URL: [?&]([^=]+)=([^&]*) with the g flag, then read $1/$2 per match instead of hand-splitting on & and =.
- About to use a pattern in .replace()? Test it here first — what highlights is exactly what .replace() will touch, capture groups included.
- Parsing multiline logs (matching a timestamp at the start of each line)? Add the m flag so ^ and $ anchor per line instead of the whole string.
- Copied a pattern from Python or PHP and it doesn't match here? Check for (?P<name>...) named groups — JavaScript uses (?<name>...), no P — or possessive quantifiers (++, *+), which don't exist in JavaScript regex.
A JavaScript regex tester, not a generic one
This tool runs JavaScript's built-in RegExp engine — the exact code path behind str.match(pattern) or pattern.test(str) in a browser console or Node.js. That's different from testing against PCRE (what PHP uses, and what many "universal" regex testers default to) or Python's re module: JavaScript has no possessive quantifiers or atomic groups, and named capture groups use (?<name>...) instead of PCRE/Python's (?P<name>...).
If you're about to ship a pattern inside JS or TypeScript — form validation, a route matcher, a log parser — testing it here means zero flavor mismatch: what highlights on this page is exactly what new RegExp(pattern, flags) matches at runtime.
Where this fits in real workflows
A regex test rarely stands alone. The usual sequence: confirm the pattern here, run the actual .replace() in your code, then diff the before/after text to make sure the substitution did what you expected and nothing else.
Extracting structured data with capture groups often feeds straight into JSON — format the extracted output to check it parsed the way you expected.
Frequently Asked Questions
Which regex flavor does this tester use?
JavaScript (ECMAScript), the engine in every browser and Node.js. Core syntax is portable, but some features differ across languages — e.g. lookbehind support and named group syntax vary in Python and Java.
Why does my pattern only find the first match?
The g (global) flag is missing. Without g, a regex stops after the first match. This tool defaults to g — check you haven't removed it.
Why does . not match my line breaks?
By default . matches any character except newlines. Add the s flag (dotall) to make . match newlines too, or use [\s\S] as a portable alternative.
What do the capture group results mean?
Each pair of parentheses in your pattern captures the text it matched. $1 is the first group, $2 the second, and so on — these are what you reference in replace operations and extraction code.
Why is my regex slow or freezing?
Likely catastrophic backtracking, caused by nested quantifiers like (a+)+ on non-matching input. Rewrite the pattern to avoid ambiguous repetition. This tool caps at 1000 matches to stay responsive.