tigtools

Regex Tester

Enter a pattern and some text to see every match highlighted, with its position and capture groups. Uses your browser's JavaScript regex engine.

Runs in your browser No sign-up

Flags

Use $1, $2 … for numbered groups, $<name> for named groups, $& for the whole match and $$ for a dollar sign.

How to use it

  1. Type a regular expression in the Pattern field, without the surrounding slashes.
  2. Tick the flags you need. g (global) finds every match instead of only the first.
  3. Paste the text to search. Matches are highlighted, and each one is listed with its index and capture groups.
  4. Optionally enter a replacement such as $2-$1 to preview the result of String.replace.

How it works

The tester runs your pattern with the browser's built-in RegExp object, so the results are exactly what JavaScript (ECMAScript) code in that browser would produce. Other languages use different regex flavours: PCRE (PHP), Python's re module, Java and .NET support features JavaScript lacks, such as possessive quantifiers (a++), atomic groups ((?>…)), inline modifiers like (?i) and recursion, and they differ in details such as \A and \Z anchors. Test a pattern in its own language before relying on it there. Lookbehind ((?<=…)), named groups ((?<name>…)) and Unicode property escapes (\p{L} with the u flag) work in all current browsers.

Without the g or y flag only the first match is found, as with RegExp.exec. Zero-length matches, for example of ^ or \b, are listed but not highlighted; after one, the search moves on by one character (one code point with the u flag), as String.matchAll does. Capture groups are shown by number and, where defined, by name; a group that did not take part in the match is marked as having no value, which is different from an empty match.

Some patterns, such as (a+)+$ on a long line without a match, take exponential time to fail (catastrophic backtracking). To reduce the risk, matching starts a moment after you stop typing, only the first 100,000 characters of the text are searched, and at most 1,000 matches are collected. A pathological pattern can still make the tab unresponsive for a while; if that happens, simplify the pattern or shorten the text.

Examples

Extracting dates

Pattern (\d{4})-(\d{2})-(\d{2}) with the g flag on “Due 2026-03-15, paid 2026-04-02” finds two matches. Group 1 is the year; the replacement $3.$2.$1 turns the text into “Due 15.03.2026, paid 02.04.2026”.

Named groups for readable code

(?<key>\w+)=(?<value>[^&]*) on the query string a=1&b=two lists key and value for each pair, which matches what match.groups.key and match.groups.value return in JavaScript.

Case-insensitive search across lines

^error:.* with the flags g, i and m matches every line of a log that starts with Error:, ERROR: or error:, because m makes ^ match at the start of each line.

Frequently asked questions

Will my regex work the same in Python, PHP or Java?

Not necessarily. This tool uses the JavaScript engine. Basic syntax is shared, but features such as possessive quantifiers, atomic groups, inline flags like (?i), and some escape sequences exist only in other flavours, and a few behave differently. Always test in the target language.

Why is only one match found?

The g (global) flag is off. Without it, JavaScript returns only the first match. Tick g to find all of them.

Should I type the slashes around the pattern?

No. Enter only the pattern, for example \d+ rather than /\d+/g, and choose flags with the checkboxes. The JavaScript literal form is shown below the results for copying into code.

Why did the page become slow with my pattern?

Nested quantifiers such as (a+)+ or (.*)* can force the engine to try an exponential number of paths when no match exists. Make the pattern more specific, for example by replacing .* with [^,]*, or use anchors. The tester limits the text to 100,000 characters to reduce the impact.

Privacy

Your pattern and text are processed only in your browser by its JavaScript engine. Nothing is uploaded, stored or included in analytics.