How to Test a Regular Expression
Regular expressions are almost impossible to get right by reading them. The only reliable way to write one is to try it against real text and watch what it catches — and, just as importantly, what it catches that you did not intend. This tester highlights every match as you type, lists each capture group, and previews a replacement before you run it anywhere that matters.
Write or load a pattern
Start from scratch, or load one of the common patterns to see how it is put together.
Paste your real text
Use actual data rather than a tidy example. Patterns fail on the messy cases, not the clean ones.
Check the groups
The table shows what each capture group actually captured, which is where most pattern bugs reveal themselves.
The Flags, and Which Ones Actually Matter
Global is the one people forget. Without it, a pattern stops at the first match, which is why a replace operation sometimes changes only the first occurrence and leaves the rest untouched. If you want every match, it is not optional.
Multiline changes what the anchors mean. By default ^ and $ match the start and end of the entire string; with multiline they match at every line break instead. For anything line-oriented — log files, lists, config — you almost certainly want it on. Separately, dot matches newline lets . cross line breaks, which it normally will not.
And a warning worth taking seriously: a pattern with nested quantifiers, something like (a+)+b, can take exponentially long on input that nearly matches. This is called catastrophic backtracking, and it is a real way to hang a server. Testing against realistic input here — and watching the execution time shown above — catches it before it reaches production.
Practical Advice
Build it up in pieces
Get one part matching, then add the next. Writing a long pattern in one go and then debugging it is far harder than growing it incrementally.
Test the cases you expect to fail
A pattern that matches your good examples is only half tested. What matters is whether it rejects the bad ones.
Use named groups for anything real
Writing (?<year>\d{4}) instead of (\d{4}) makes the pattern self-documenting and the extraction code readable months later.
Do not parse HTML with regex
It is the classic mistake. HTML nests arbitrarily and regex cannot express that. Use a parser - regex is fine only for a rough scan.
Frequently Asked Questions
How do I test a regular expression online?
Type your pattern and paste your text. Matches highlight instantly and every capture group is listed. Free, no signup.
Is my text uploaded to a server?
No. Everything runs in your browser, which matters when testing patterns against log files or customer data.
What does the global flag do?
It finds every match rather than stopping at the first. Forgetting it is why a replace sometimes changes only the first occurrence.
What is the difference between multiline and dot-matches-newline?
Multiline changes where ^ and $ match, at every line rather than the whole string. Dot-matches-newline lets a dot cross line breaks.
What are capture groups?
Parentheses that extract part of a match. The groups column shows exactly what each one captured, which is where most bugs show up.
How do I use groups in a replacement?
Refer to them as $1, $2 and so on. So $2/$1 on a date pattern swaps the first two captured parts around.
What are named groups?
Groups written as (?<name>...), which makes both the pattern and the extraction code far easier to read.
Which regex flavour is this?
JavaScript, which is close to but not identical with PCRE. Lookbehind is supported in modern browsers; recursion and possessive quantifiers are not.
Why is my pattern extremely slow?
Probably catastrophic backtracking from nested quantifiers like (a+)+. Watch the execution time and simplify the pattern if it climbs.
Can I use this for email validation?
For a rough check, yes. Fully correct email validation by regex is famously impractical - the included pattern is deliberately permissive.
Why is the match count capped?
At a thousand matches, to keep the page responsive. The pattern still runs correctly; only the display is limited.
Is this regex tester really free?
Completely free, with no limits, no signup and no premium wall. Everything runs in your browser.
Last updated: July 21, 2026 · FlipMyFormat Regex Tester
Written and maintained by the FlipMyFormat team
