Skip to content

Regex Tester

Write a regular expression and see every match, group and replacement as you type, with the pattern explained in plain English.

Key facts

  • JavaScript has eight regex flags: d, g, i, m, s, u, v and y. The v flag (ES2024) is a stricter u that adds set operations like [\p{L}--[a-z]].
JavaScript
120 characters
Link optionspattern only

The address bar holds the pattern, flags and replacement, so Copy link shares them. Your test text stays out of it unless you include it (up to 2,000 characters), because it may be private. Nothing is sent to a server.

Matches

3matches

The first is “2026-10-08”, at position 27.

Groups
year, month, day
Characters matched
30 of 120
What the pattern meansHover or tap a part to see it in the pattern and what it matched
How this works: Method, 3 sources, Checked against 25 worked examples,

How this works

Method

Your pattern runs in your own browser’s JavaScript engine, in a background worker that is stopped after 1.5 seconds, so a pattern that backtracks catastrophically can’t freeze the page. The explanation comes from our own parser of the ECMAScript pattern grammar, checked against the engine; what each part matched is found by wrapping that part in one more group and running the pattern again. Conversions to other flavours only rewrite the syntax and list what their documentation says works differently.

How it’s tested

25 worked examples for this page are checked by automated tests before every release: given the inputs, the tool must show the expected answer.

Changes

  • First published, with a library of 19 common patterns and their test cases.

How we make toolsReport a mistake

All 19 patterns

Web and network · Dates, numbers and IDs · Forms and text
JavaScript regex cheat sheetThe syntax this tester runs, on one screen
JavaScript regular expression syntax
SyntaxMeans
.Any character except a line break (with the s flag, any character at all)
\d \w \sA digit, a word character (A–Z, a–z, 0–9, _), a whitespace character
\D \W \SAnything but a digit, a word character, whitespace
[abc] [^abc] [a-z]One of a, b or c; anything but a, b or c; a to z
^ $Start and end of the text (of each line, with the m flag)
\b \BA word boundary; not a word boundary
* + ? {3} {2,5}Zero or more, one or more, optional, exactly 3, 2 to 5
*? +? {2,5}?The same, but as few as possible (lazy)
(abc)A capturing group, numbered from 1 by its opening bracket
(?<name>abc)A named capturing group
(?:abc)A group that doesn’t capture
(?=abc) (?!abc)Followed by, not followed by (lookahead)
(?<=abc) (?<!abc)Preceded by, not preceded by (lookbehind)
\1 \k<name>The text a group matched, again (a backreference)
a|ba or b
\p{L} \p{Lu} \p{Script=Greek}A Unicode letter, uppercase letter, Greek character (needs u or v)
\n \t \x41 \u00e9 \u{1F600}Line feed, tab, a character by hex code (\u{…} needs u or v)
g i m s u v y dFlags: global, ignore case, multiline, dot-all, Unicode, Unicode sets, sticky, indices

Sources

Frequently Asked Questions

How do I test a regular expression?

Type the pattern in the first box, without the slashes, and pick its flags. Paste the text to search below it: every match lights up, each capture group in its own colour, and the list beside it gives each match’s position and group values. Switch to Replace to try a replacement.

Which regex flavour does this tester use?

JavaScript’s, run by your own browser, so what you see is exactly what RegExp, match() and replace() will do in your code. The section on other languages converts the pattern’s syntax for Python, PCRE, Go, Java and .NET and warns where they behave differently, but it doesn’t run those engines.

Why did my pattern time out?

Some patterns, such as (a+)+ followed by something that fails, can try every way of splitting the text between their nested repeats. The work doubles with each extra character, which is called catastrophic backtracking. The tester stops a run after 1.5 seconds and points at the part to rewrite, usually by removing the inner repeat or making the options of a repeated group unable to match the same text.

How do I use a capture group in the replacement?

Write a dollar sign and the group’s number, such as $1 for the first group, or a dollar sign and the group’s name in angle brackets for a named group. A dollar sign and an ampersand inserts the whole match, and two dollar signs insert a single one. The replace box shows the result live.

Is my text sent anywhere?

No. Matching runs in your browser, in a background worker on this page. The pattern, flags and replacement go in the page’s address so you can share them; your test text stays out of the address unless you choose Include test text in link under Link options (up to 2,000 characters).