Regex Tester
Enter a pattern and some test text, and see exactly what it matches — useful for building a regex from scratch or figuring out why an existing one isn't working.
Overview
Regular expressions are compact but easy to get subtly wrong — a quantifier in the wrong place, a forgotten escape character, or a missing flag can silently change what a pattern matches. Rather than testing a pattern by running it inside actual application code, this tool lets you iterate on a pattern and test text side by side and see results immediately, which is faster for exploring how a regex behaves.
Matching uses JavaScript's native RegExp engine — the same one that runs in every browser and in Node.js. That means what you see here is exactly how the pattern will behave in real JavaScript code, not an approximation from a different regex flavor. If you're writing a pattern for a `.match()`, `.test()`, or `.replace()` call, or a validation rule in a form, this is the same engine that will run it.
Flags change matching behavior and are easy to forget: `g` (global) finds every match instead of stopping at the first, `i` (case-insensitive) ignores letter case, and `m` (multiline) changes how `^` and `$` behave across line breaks. Getting an empty or unexpected result is very often a missing flag rather than a wrong pattern.
Examples
Extracting numbers
Pattern: \d+ Flags: g Text: Order 123, ref 456
Match 1: "123" Match 2: "456"
How It Works
- Enter your regular expression pattern in the pattern field (without the surrounding slashes).
- Add any flags you need, such as "g" for global matching or "i" for case-insensitive matching.
- Paste or type the text you want to test the pattern against.
- Submit to see every match found, in order.
- Adjust the pattern or flags and re-test until the results match what you expect.
Use Cases
Validating user input
Test a pattern intended for form validation (email format, phone number, postal code) against a range of valid and invalid sample inputs before putting it into code.
Extracting data from text
Build a pattern to pull specific values — IDs, dates, URLs — out of log lines or unstructured text, and confirm it captures every instance.
Debugging an existing regex
Paste in a pattern from existing code that isn't matching as expected, and test it against real sample text to see exactly where it diverges.
Learning regex syntax
Experiment with quantifiers, character classes, and groups against small test strings to see their effect immediately, without writing and running code.
Tips
- Without the "g" flag, a pattern only reports its first match, even if the text contains more.
- Special characters like `.`, `*`, `+`, `?`, `(`, and `)` need to be escaped with a backslash if you want to match them literally.
- `^` and `$` match the start and end of the whole string by default — add the "m" flag if you need them to match the start and end of each line instead.
- Greedy quantifiers like `.*` match as much as possible; add `?` after them (`.*?`) to match as little as possible instead.
- If a pattern matches nothing, test a much simpler version of it first, then add complexity back piece by piece to find where it breaks.
FAQ
No. Matching runs entirely in your browser using JavaScript's native RegExp engine.
JavaScript's (ECMAScript) regex flavor — the same engine your browser and Node.js use. Syntax can differ slightly from PCRE, Python, or other flavors.
Check your flags — a pattern without the "g" flag only reports the first match, and case sensitivity depends on the "i" flag.
Yes. Groups defined with parentheses are shown alongside each full match, so you can confirm both the overall match and the specific pieces you're capturing.
Yes, since JavaScript's RegExp engine supports named groups (`(?<name>...)`) natively — they behave the same way here as in application code.