Regex Tester
Write a regular expression and see immediately what it matches in your test text, with the matches highlighted as you type.
Uses the browser's own JavaScript regex engine, so behaviour matches what your code will do exactly.
This tool runs entirely in your browser
This tool runs entirely in your browser. The data you paste is processed on your device and never sent to Filorra.
That is not a small detail for developer tools. API responses, tokens, config files, and log excerpts routinely contain credentials and customer data, and pasting them into a server-side tool means disclosing them to a third party.
How to use Regex Tester
Enter your pattern
Set the flags you need — global, case-insensitive, multiline.
Paste test text
Matches highlight live as you edit either field.
Refine until it fits
Adjust the pattern against real data, including the cases that should not match.
Greedy versus lazy quantifiers
This is the first thing that surprises people, and it explains most "why is my match too long" questions.
Quantifiers such as `*` and `+` are greedy: they consume as much as they can and then give back only what is needed for the rest of the pattern to succeed. So `<.+>` against `<b>bold</b>` matches the entire string, not just `<b>` — the `.+` swallows everything and backtracks only to satisfy the final `>`.
Adding `?` makes a quantifier lazy: `<.+?>` stops at the first `>` and matches just `<b>`. When a match extends further than intended, a lazy quantifier is usually the fix.
Often a better fix is a negated character class. `<[^>]+>` says "one or more characters that are not a closing bracket", which expresses the intent directly and runs faster than backtracking.
The global flag keeps state, and it will bite you
A regex with the `g` flag maintains a `lastIndex` property between calls, and this causes a genuinely baffling class of bug.
Calling `.test()` repeatedly on the same global regex object returns alternating true and false for identical input, because each successful call advances `lastIndex` and the next search starts from there. A regex stored in a module-level constant and reused across function calls behaves inconsistently for exactly this reason.
Avoid it by not using `g` with `.test()`, by creating the regex fresh where it is used, or by resetting `lastIndex` to zero before each call. The same applies to `.exec()` in a loop, where the state is what makes the loop work — which is why the behaviour exists at all.
Catastrophic backtracking
Some patterns take exponential time on inputs that are only slightly wrong, which turns a validation regex into a denial-of-service vector.
It arises from nested quantifiers where the engine has many equivalent ways to split the input — patterns of the form `(a+)+b` are the classic demonstration. Against a long string of `a` characters with no `b`, the engine explores every possible division before concluding there is no match, and the work doubles with each additional character.
The practical defence is to avoid nesting quantifiers, prefer specific character classes over `.*`, and anchor patterns so the engine can fail fast. Test with deliberately long non-matching input — a pattern that is instant on your examples and hangs on a 40-character string is exactly the failure you want to find before it reaches production.
Do not use a regex for email validation
Fully validating an email address against the RFC grammar takes a pattern thousands of characters long, and it still cannot tell you whether the mailbox exists.
The pragmatic approach is a loose check — something non-empty, an `@`, something with a dot — and then send a confirmation email. Delivery is the only real proof. Strict patterns mostly succeed at rejecting valid addresses containing apostrophes, plus tags, or newer top-level domains.
When to use Regex Tester
- Building a pattern to extract fields from log lines.
- Working out why a validation regex rejects valid input.
- Constructing a find-and-replace for a bulk edit.
- Testing a pattern against edge cases before shipping it.
Common problems
- My match is longer than expected.
- Greedy quantifiers consume as much as possible. Use a lazy quantifier with ? or a negated character class such as [^>]+.
- test() alternates between true and false.
- The global flag keeps lastIndex between calls. Drop g for test(), or reset lastIndex to zero first.
- The browser hangs on certain input.
- Catastrophic backtracking from nested quantifiers. Restructure the pattern, avoid nesting, and anchor it so it fails fast.
- The pattern works here but not in my other language.
- Regex dialects differ. JavaScript lacks lookbehind in older engines and handles named groups and Unicode classes differently from PCRE or Python.
Frequently asked questions
- Is my test data sent to a server?
- No. Matching uses the browser's built-in RegExp engine, so log excerpts and sample data stay local.
- Why does my pattern match too much?
- Quantifiers are greedy by default. Add ? to make them lazy, or use a negated character class to express the boundary directly.
- Why does test() give inconsistent results?
- A global-flagged regex remembers lastIndex between calls. Remove the g flag for test(), or reset lastIndex each time.
- Will these patterns work in Python or PCRE?
- Basic syntax transfers, but lookbehind support, named groups, and Unicode handling differ. Test in your target language.
Learn more
Guides and answers that explain how this tool's job actually works.
- ArticleReading Regex Without Fear