Test a regular expression and understand what each token does
A regex that works on the happy path and fails quietly in production is the most common kind of bug you cannot see. This tester shows every match, every capture group and a plain-English reading of the pattern.
- Flags
- g, i, m, s, u
- Groups
- Named + numbered
- Engine
- Browser native
How to use it
- Write the pattern Type the expression without the delimiters. Add flags in the box next to it: g for global, i for case-insensitive, m for multiline, s for dot-matches-newline and u for full Unicode.
- Paste the subject text The sample text is scanned live. Every match is highlighted, and the number of matches, the capture groups and the match offsets are reported.
- Read the breakdown Each token in the pattern is explained in plain English, so a pattern copied from a forum post becomes something you can defend in a code review.
Reference
Tokens explained
| Token | Meaning |
|---|---|
| `^` | Start of the line |
| `(? | A named group capturing exactly four digits |
| `[-/]` | Either a hyphen or a slash as the separator |
| `(?=\d{2})` | A lookahead asserting two digits follow, without consuming them |
| `$` | End of the line |
Questions people ask
Does the tester support every regex flavour?
It supports JavaScript regular expressions, which is what your browser uses. Python, Go, Java and .NET have small differences — Python adds A and Z anchors and named groups with a different syntax, and Go and Rust do not support lookbehind at all.
What does the g flag do?
It makes matching continue past the first hit. Without it, most methods return only the first match. The tester always reports every match regardless of the flag, and the flag mainly changes what find and replace do.
Why is my capture group empty?
Usually an optional group that did not participate in that particular match, a group inside a negative lookahead, or a group that was reset because the engine took a different path through the pattern.
What is a lookahead?
A zero-width assertion. A positive lookahead such as (?=d{2}) checks that two digits follow without consuming them, and a negative lookahead such as (?!http) checks that something does not follow. It is how you express a constraint that is not part of the value you want to keep.
How do I make a pattern match across multiple lines?
Add the m flag for the anchors to match at each line boundary, and the s flag if the dot should also match a newline character.
Is my test text sent anywhere?
No. Both the pattern and the sample text are processed by the browser’s engine on your machine. This matters more here than in most tools, because test data is often a real customer record.
Details that catch people out
This uses the browser’s own RegExp engine, so the syntax is JavaScript’s: no lookbehind before a quantifier, no possessive quantifiers, and no z or A anchors. If your backend is Python, Go or Rust, check the dialect before you copy a pattern across.
A pattern with nested quantifiers such as (a+)+ can take exponential time on a long non-matching input and lock the tab. If the tester appears to hang, look for that shape first — nested quantifiers are the usual cause.
Where this earns its keep
Validating a date pattern
Test a date regex against a mixed batch of valid and invalid strings to see exactly which ones slip through. A pattern that matches 2026-13-45 is worse than no pattern at all.
Extracting fields from a log line
Build the expression against a real log line, then confirm the capture groups land on the right values before putting it into the parser.
Checking a pattern someone sent you
A regex pasted into a chat message is often a service-wide destructive replacement. Test it against real data and read the explanation before you deploy it.
Guides that go deeper
- Twelve Regular Expressions Worth Knowing by Heart 8 min read · Twelve regular expressions for the tasks that come up in every project: email, URL, dates…
- Quoting and Escaping in Shell Commands 9 min read · Why unquoted variables break, the difference between single and double quotes, and how to…
- How SQL Injection Works, and How to Prevent It 9 min read · What SQL injection is, how string concatenation creates it, why parameterised queries fix…
Last reviewed 2026-10-13. Every tool on DevSnap runs entirely in your browser, so whatever you paste here never reaches a server.