Free tool
Regex Tester
Test a pattern against real text and see every match and capture group as you type.
Type a pattern and some text to see every match highlighted as you go, with each capture group and named group listed separately. There is a replacement preview too, so you can check a substitution before running it over anything real. Everything happens in your browser tab.
This uses the JavaScript regular expression engine, which is the same one your browser and Node use. Most syntax is shared across languages, but a few things are not: JavaScript has no atomic groups or recursion, lookbehind is comparatively recent, and \d matches only ASCII digits unless you add the unicode flag. If a pattern behaves differently in Python or PCRE, that is usually why.
How to use it
- Type your pattern, without the surrounding slashes.
- Toggle the flags you need. Global and ignore-case are on by default.
- Paste your test text and watch the matches highlight.
- Add a replacement to preview a substitution, using $1 for the first group.
Frequently asked questions
Why does my pattern find only the first match?
The global flag is off. Without g, the engine stops at the first match. It is on by default here, so if you have turned it off that is the cause.
How do I match across multiple lines?
Two different flags, often confused. The s flag makes a dot match newlines as well. The m flag makes ^ and $ match at each line boundary rather than only at the very start and end of the string.
What is the difference between greedy and lazy?
By default a quantifier is greedy and takes as much as it can, so .* on an HTML tag swallows the whole line. Adding a question mark makes it lazy, so .*? stops at the first thing that lets the rest of the pattern succeed.
How do I refer to a capture group in a replacement?
Use $1, $2 and so on by position, or $<name> for a named group written as (?<name>...). A literal dollar sign is written $$.
Why does my pattern hang the page on some input?
Catastrophic backtracking. Nested quantifiers over overlapping alternatives, such as (a+)+b, can take exponential time on a failing input. Prefer more specific character classes and avoid nesting quantifiers inside groups that already repeat.
The desktop version
Regex Tester in Toolbelt
This page does the job in a browser tab. Toolbelt is the same tool as a native Mac app, plus the things a web page cannot do.
Tools
{
"name": "Holizmi",
"tools": [
"json",
"jwt",
"base64"
],
"live": true
}{
"sub": "12345",
"name": "Henry",
"exp": 1767225600
}019bd4e2-7a10-7c3e-9f21-4a6b8d3e5c07
019bd4e2-7a11-7b8a-8e44-1c2f9a7d6b13
019bd4e2-7a12-7d5f-b0c9-7e3a1f8c2d95 1 1 one
2 2 two
3 + inserted
3 4 three- Run a pattern across every file in a folder
- Export the pattern as JavaScript, Python, Go or PHP source
- Keeps a library of the patterns you actually reuse
- Works with no connection at all