Regex Tester: Online JavaScript Regex Checker

Test a regular expression with every match highlighted, capture and named groups, and a live replace preview. Free, no sign-up, and it runs in your browser.

//g
Type the pattern without the surrounding slashes. Use \d, not \\d.
Flags
g global · i ignore case · m multiline · s dotAll · u unicode · v unicode sets · y sticky · d match indices
$1 numbered group · $<name> named group · $& whole match · $$ a literal $
–
Matches highlighted
Replace result

Matching runs in a background worker and is stopped after 0.5 s, so a runaway pattern cannot freeze the page. Nothing you type is uploaded.

Match details

#PositionMatchCapture groups

Common regex patterns

Click a pattern to load it with sample text. They are practical patterns, not full validators.

How this regex tester works

This tester uses your browser's own JavaScript RegExp engine, the same one your front-end code and Node.js use, so a pattern that works here behaves the same in String.prototype.match, matchAll, replace and test. Each time you type, the pattern is compiled with the flags you ticked and run against the test string. Matches are highlighted, listed with their start and end positions, and every capture group is shown, both numbered and named.

Everything happens on your device. The pattern and text are never sent anywhere, which matters when you are testing against log lines, customer data or API keys.

Worked example: named groups and replace

The default pattern finds ISO dates and names each part: \b(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01])\b. On the sample text it finds 2 matches. The first is 2026-10-20 at position 9, with year = 2026, month = 10 and day = 20. The text 2026-13-01 is skipped because the month group only allows 01–12.

With the replacement $<day>/$<month>/$<year> the result becomes: Released 20/10/2026, patched 03/11/2026. Not a date: 2026-13-01. Named references like $<day> are easier to read than $3 and keep working if you add another group later.

Backreferences work inside the pattern too. \b(\w+)\s+\1\b with the gi flags finds a word followed by the same word, and replacing with $1 turns This is is a test of the the repeated word finder. into This is a test of the repeated word finder..

What the flags do

g (global) finds every match instead of stopping at the first. Without it, replace changes only the first match: replacing \d+ with # in “a1 b22 c333” gives “a# b22 c333”, while with g it gives “a# b# c#”.

i ignores case. m (multiline) makes ^ and $ match at the start and end of every line, which is what you want when testing a list of values one per line. s (dotAll) lets . match newlines too.

u (unicode) treats emoji and other characters outside the Basic Multilingual Plane as one character, enables \p{…} property escapes such as \p{L} for any letter, and makes the parser strict about invalid escapes. v (unicodeSets) is the newer version of u (ES2024): it adds set operations in character classes like [\p{L}--[a-z]]. You cannot combine u and v. The v box is hidden if your browser does not support it.

y (sticky) only matches starting exactly at lastIndex, which is useful for writing tokenizers. d (indices) records the start and end of each capture group; the positions appear in square brackets in the match table.

Catastrophic backtracking and the 0.5 second limit

JavaScript uses a backtracking regex engine. Patterns with nested or overlapping quantifiers, such as (a+)+$ or (\w+\s?)*$, can take exponentially longer as the input grows when there is no match, because the engine tries every way of splitting the text between the quantifiers. On a server this is a denial-of-service risk (ReDoS); in a browser it freezes the tab.

This tester runs matching in a Web Worker and stops it after 500 milliseconds, then tells you the pattern is too slow. To fix a slow pattern, make each repeated part match something the next part cannot: \w+(?:\s\w+)* instead of (\w+\s?)*, and prefer specific classes like [^"]* over .*.

JavaScript regex tips and gotchas

Escaping in strings. In a regex literal you write /\d+/, but in new RegExp("\\d+") the backslash must be doubled because the string is parsed first. Enter patterns here as you would write them between slashes.

Reusing a global regex. A regex with g or y keeps its lastIndex between calls, so calling test() twice on the same object can alternate between true and false. Use matchAll, or reset lastIndex.

Differences from PCRE and Python. JavaScript supports lookahead, lookbehind, named groups and Unicode property escapes, but not possessive quantifiers, atomic groups, \A/\Z or recursion. Inline modifiers are only supported in recent browsers, and only in the scoped form (?i:…). A pattern copied from another language may need small changes.

Validation patterns are approximations. The email and URL patterns in the library catch typos, but the only real test of an email address is sending a message to it. If you are moving config between formats, our YAML to JSON converter validates the syntax for you, and the Markdown to HTML converter turns README files into clean HTML.

Regex Tester: frequently asked questions

Which regex flavour does this tester use?

It uses the JavaScript RegExp engine built into your browser, so results match what you get in JavaScript and Node.js. Other flavours such as PCRE (PHP), Python re and Java are similar but not identical; for example JavaScript has no possessive quantifiers or atomic groups.

How do I use capture groups in the replacement?

Use $1, $2 and so on for numbered groups, $<name> for a named group written as (?<name>...), $& for the whole match, and $$ for a literal dollar sign. Without the g flag only the first match is replaced, exactly as in String.prototype.replace.

Why does my regex only find one match?

Without the g (global) flag JavaScript stops after the first match. Tick the g box to find every match. If you use ^ and $ to match whole lines in a multi-line list, also tick m (multiline), otherwise ^ and $ only match at the very start and end of the text.

Why did the tester stop with a timeout warning?

Your pattern took longer than 0.5 seconds, which almost always means catastrophic backtracking caused by nested or overlapping quantifiers such as (a+)+ or (.*)*. Rewrite the pattern so each repeated part cannot match the same characters in more than one way.

What is the difference between the u and v flags?

Both turn on full Unicode mode, so emoji count as one character and property escapes like \p{L} work. The v flag (unicodeSets, added in ES2024) also allows set subtraction and intersection inside character classes and is stricter about some characters. The two flags cannot be used together.

Can I test Python, Java or PHP regex here?

Mostly, yes. This regex tester runs the JavaScript engine, and the core syntax (character classes, quantifiers, groups, anchors and lookahead) works the same in Python, Java, PHP and .NET. Differences show up in the details: Python writes named groups as (?P<name>...), JavaScript has no possessive quantifiers or atomic groups, and lookbehind support varies. Test the basics here, then confirm edge cases in your own language.

Is my test data sent to a server?

No. The pattern and test text are processed entirely in your browser by a background script on this page. Nothing is uploaded or stored, so it is safe to test against logs or other private data.