How to Test a Regular Expression
Regular expressions are compact to the point of being cryptic, which is why writing one blind and hoping it works is a recipe for frustration. This tester gives you the feedback loop that makes them tractable. Type your pattern and paste the text you want to search, and matches light up inside the text immediately — so you can see not just whether the pattern works, but exactly what it caught and what it missed. Below that, a table breaks down every match: its position in the string, the matched text, and the contents of each capture group, shown by name when you use named groups. Toggle any of the six flags with a tap; each one explains what it does, so you don't have to remember whether m or s is the multiline one. Switch on replace mode to preview a substitution live, using $1 and $2 or named references, which is the fastest way to verify a find-and-replace before running it on real data. Invalid patterns show the engine's own error message rather than failing quietly, and match scanning is capped so a runaway pattern can't lock up the page. Everything runs in your browser, so patterns and sample data stay on your device.
Enter your pattern
Type the expression and toggle the flags you need.
Paste test text
Matches highlight instantly with a full breakdown below.
Refine or replace
Adjust until it's right, then preview a replacement.
Flags Explained
| Flag | Name | Effect |
|---|---|---|
| g | global | Find all matches, not just the first |
| i | ignore case | Match regardless of capitalisation |
| m | multiline | ^ and $ match at each line break |
| s | dot all | . also matches newline characters |
| u | unicode | Treat the pattern as Unicode code points |
| y | sticky | Match only from the exact lastIndex position |
Common Use Cases
Validate input formats
Check an email, phone or postcode pattern against real examples.
Extract data from logs
Pull timestamps, IPs or error codes out of log lines.
Bulk find and replace
Preview a substitution before running it across a codebase.
Parse structured text
Capture fields from semi-structured records.
Clean up messy data
Strip unwanted characters or normalise spacing.
Route and redirect rules
Test patterns used in web server and router configuration.
Learning regex
Experiment safely with instant feedback and a cheatsheet.
Debug a failing pattern
See exactly which part of the text your regex is or isn't catching.
Tips & Best Practices
Build up in small steps
Start with a simple pattern that matches too much, then tighten it piece by piece.
Prefer lazy quantifiers
Use *? or +? when greedy matching swallows more than you intended.
Use non-capturing groups
Write (?:…) when you only need grouping, keeping your capture numbers clean.
Name your groups
(?<year>\d{4}) is far more readable than remembering what $3 was.
Watch catastrophic backtracking
Nested quantifiers like (a+)+ can explode in cost — restructure rather than nest.
Escape special characters
A literal dot, slash or bracket needs a backslash, or it means something else entirely.
Troubleshooting
Only the first match is found
Turn on the g flag. Without it the engine stops after the first match.
^ and $ don't match my lines
Enable the m flag so they anchor to each line rather than the whole string.
My dot won't match a newline
That's by design. Turn on the s flag to make . match newline characters too.
The pattern is reported invalid
The exact engine error is shown — usually an unclosed group, bracket or a stray backslash.
Frequently Asked Questions
How do I test a regex for free?
Enter your pattern and paste some test text above. Matches highlight instantly with a full breakdown — free, no signup.
Which regex flavour does it use?
The JavaScript engine built into your browser, which matches how regex behaves in Node.js and front-end code.
Does it support named capture groups?
Yes. Groups written as (?<name>…) are shown by name in the match table.
Can I preview a replacement?
Yes. Turn on replace mode and use $1, $2 or named references to see the substituted output live.
What do the flags do?
g finds all matches, i ignores case, m makes ^ and $ per-line, s lets . match newlines, u enables Unicode mode and y makes matching sticky.
Why does only one match show?
The g flag is off. Enable it to find every match rather than stopping at the first.
Does it show match positions?
Yes. The details table lists the index of every match in the test string.
What happens with an invalid pattern?
You see the engine's own error message, such as an unterminated group, instead of a silent failure.
Can a bad pattern freeze the page?
Match scanning is capped, so a runaway or pathological pattern can't lock up your browser.
Is my pattern or data sent anywhere?
No. Everything runs in your browser, so nothing leaves your device.
Does it work with Python or PCRE regex?
Most syntax is shared, but some constructs like lookbehind support and named group syntax differ between flavours.
How many matches can it show?
The table lists up to two hundred matches, while the count reflects everything found.
Can I copy the matches?
Yes. One click copies all matched strings, or the full replaced text in replace mode.
What is a non-capturing group?
(?:…) groups part of a pattern without creating a numbered capture, keeping your group numbers tidy.
What is catastrophic backtracking?
Nested quantifiers can make the engine try exponentially many paths. Restructure the pattern rather than nesting quantifiers.
Does it work offline?
Once the page has loaded it runs entirely in your browser, so it keeps working without a connection.
Does it work on phones?
Yes, in any modern browser on Windows, Mac, Android or iPhone with nothing to install.
Is this tool really free?
Completely free, forever — no account, no ads and no premium wall.
100% free · No signup · Processed in your browser · Data never sent
Last updated: August 2026 · FlipMyFormat Regex Tester
Written and maintained by the FlipMyFormat team · Runs entirely in your browser