Regex Tester

Write a regular expression and watch it match against your sample text as you type, with every match highlighted and every capture group listed.

Runs entirely in your browser. Nothing is uploaded.

//g

Test against real text, not imagined text

Most regex bugs are not errors in the pattern - they are wrong assumptions about the input. The sample you had in mind was clean; the actual data has trailing whitespace, Windows line endings, an empty field, or a character you forgot people use in names.

Pasting genuine sample text and watching the highlighting update as you type surfaces those cases immediately. It is a much faster loop than editing a pattern in application code and rerunning the whole thing to find out.

The flags that change everything

The global flag decides whether you get the first match or all of them - the usual cause of a pattern that works in a tester and processes only one item in code. The ignore-case flag does what it says. The multiline flag redefines the anchors so they match at each line break instead of only at the start and end of the whole string.

The dot-all flag is the one people reach for last and need most often: without it, a dot does not match a newline, so a pattern intended to capture a block spanning several lines silently matches nothing.

Greedy, lazy and catastrophic backtracking

Quantifiers are greedy by default: they consume as much as possible and give back only when forced. This is why a pattern meant to grab one HTML tag swallows everything up to the last closing bracket on the line. Adding a question mark makes the quantifier lazy and stops at the first match instead.

Nested quantifiers deserve real caution. A pattern with a repeated group that can itself repeat can take exponential time on input that nearly matches but ultimately fails - the failure mode known as catastrophic backtracking, and a genuine denial-of-service vector when the pattern runs against user input on a server. If a pattern hangs here on a modest sample, it will hang in production too.

Frequently asked questions

Which regex flavour does this use?
JavaScript regular expressions, since it runs in your browser. Syntax is close to PCRE for everyday patterns, but lookbehind support and some Unicode property escapes differ from Python or PHP.
Why does my pattern only find the first match?
The global flag is off. Without it, matching stops after the first result. This is the most common difference between a pattern that looks right in a tester and one that misbehaves in code.
Why does my pattern not match across lines?
By default a dot does not match a newline. Enable the dot-all flag for that, or the multiline flag if what you need is for the anchors to match at each line break.
Is my test data uploaded?
No. Both the pattern and the sample text stay in your browser, which matters when the sample is a real log file.
Why did my regex hang the page?
Almost certainly catastrophic backtracking from nested quantifiers on input that nearly matches. The same pattern will hang on a server, so rewrite it rather than working around it.