🔍 Regex Tester
Test and debug regular expressions with real-time matching
✓ Free Forever · ✓ No Signup · ✓ No Upload · ✓ Works Offline
🔒 Your text never leaves your device. All processing happens locally in your browser using JavaScript RegExp engine. No upload, no server, no tracking.
Features
- Real-Time Matching — See matches highlighted instantly as you type your pattern and test string.
- Capture Groups — View captured groups for each match — essential for complex patterns.
- Find & Replace — Test a replacement (\n for a line break, $1 or $<name> for a group) and copy the result.
- Common Patterns — Quick-load common patterns for email, URL, phone, IP, and date validation.
How It Works
- Enter a regex pattern — Type your regular expression and set flags (g, i, m, s, y, u, v).
- Enter test text — Paste the text you want to match against.
- Review matches — See highlighted matches, capture groups, and optionally test replacements.
Use Cases
- Debug and test regex patterns before using them in code
- Validate email, URL, or phone number patterns
- Search and replace text with complex pattern matching
Frequently Asked Questions
What regex flavor is used?
JavaScript's built-in RegExp engine, which supports standard features including lookahead, lookbehind, named groups, and Unicode escapes.
Which flags can I use?
g, i, m, s, y (sticky: a match must start exactly where the last one ended), u and v (Unicode sets, in browsers that have it). u and v can't be on together — JavaScript refuses that — so turning one on turns the other off. Paste a literal like /\d+/gi and the pattern and its flags are filled in.
Are the common patterns reliable?
They are starting points tuned to skip what usually sits next to the real thing: Phone needs at least 7 digits and doesn't fire on dates, plain numbers or IP addresses; IP Address only takes parts from 0 to 255; Date takes YYYY-MM-DD or YYYY/MM/DD with month 1–12 and day 1–31 (it doesn't know that February has no 30th); URL leaves a sentence's final full stop or closing bracket out. For production validation, test them with the edge cases of your own data.
How do I replace with a line break, or with a group?
Type \n for a line break and \t for a tab: with "Read \n, \t…" ticked (it is by default) they work the way they would inside a JavaScript string; untick it to insert the backslash itself. Groups are $1, $2…, a named group is $<name>, the whole match $&, a literal dollar $$. JavaScript doesn’t read \1, $0 or ${1} in a replacement — the page tells you when it sees one. Without the g flag only the first match is replaced, and the page says how many there are in all.
Notes from Milo 🐨
The replace box couldn't do the commonest replacement there is: "turn these commas into new lines". A one-line box can't hold a line break, and typing \n put a backslash and an n in the result. Now \n, \t and \r work the way they would in a JavaScript string (there's a tick box if you really want the backslash). If you come from sed, Python or .NET and type \1, $0 or ${1}, the page tells you JavaScript wants $1 or $&. With g off it now says how many matches there are in all instead of just "1", every match shows its line and column, and there are Copy buttons for the result and for the pattern as a /…/ literal.
I pasted an ordinary order e-mail into the tester and clicked my own Phone pattern: it "found" the order date and the total as phone numbers. The IP pattern took 999.999.999.999, Date took the 13th month, and URL swallowed the full stop at the end of the sentence. All five common patterns are tighter now (and the FAQ says exactly what each one checks). Also new: the sticky (y) and Unicode-sets (v) flags, so a literal like /…/v pasted from your code works instead of throwing a confusing error, named groups in any language (?<年>…) get their labels, and an empty match — what a* or ^ finds — is shown as one instead of an invisible blank.
Related Tools
- 🔢 Word Counter — Analyze text — word count, characters, reading time, and top words
- 🧹 Remove Duplicates — Remove duplicate lines from text with sorting and trimming options
- 🔗 URL Encoder / Decoder — Encode or decode URLs and query strings instantly
💬 Bug, idea, or just to say hi? Tell Milo 🐨 · [email protected]