Regex Tester
Test patterns with live match highlighting.
Runs on this deviceSent to a server: 0 bytes
How it works
- Type, paste or pick what you're working with.
- Set the options you need.
- Copy or download the result. It's made on this device.
Runs a regular expression against sample text with live highlighting, so you can see what a pattern matches — and what it unexpectedly also matches — before it reaches your code.
The flags that change everything
g finds every match rather than stopping at the first. i ignores case. m makes ^ and $ match at each line rather than only at the start and end of the whole string. s lets . match a newline, which it otherwise never does. Most patterns that “work in testing but not in production” differ only by a flag.
Greedy versus lazy
Against <b>one</b> and <b>two</b>, the pattern <.+> matches the entire line in one go, because + takes as much as it can and then backtracks just enough to succeed. Writing <.+?> makes it lazy, and it matches each tag separately. This one character is behind a large share of regex bugs.
Nested quantifiers can hang the page
A pattern like (a+)+$ tried against a long non-matching string forces the engine through an exponential number of possibilities — catastrophic backtracking, and the mechanism behind a class of denial-of-service bug in real systems. If a pattern with a quantifier inside a quantified group seems to freeze on a long input, that is what is happening. And the standing advice holds: HTML is not a regular language, so parse it with a parser rather than a pattern.
Questions
Which regex flavour does this use?
JavaScript's, since it runs in your browser. It is close to PCRE for everyday patterns, but lookbehind support varies by browser and some PCRE features — recursion, possessive quantifiers — do not exist in JavaScript at all.
Is Regex Tester free to use?
Yes. Regex Tester is completely free, with no account, no sign-up and no usage limits.
Are my files or data uploaded anywhere?
No. Regex Tester runs entirely in your browser. Your files, text and numbers are processed on your own device and are never uploaded to a server.
Does Regex Tester work offline?
Yes, once you have opened it. NWS Kit installs as a Progressive Web App and keeps working with no connection. Video and audio tools download their engine (about 32 MB, from nwskit.com) the first time one is used; save the Video and audio pack to have it ready offline.
Do I need to install any software?
No installation is required. Regex Tester works in any modern browser on desktop or mobile.