Regex Tester

Test JavaScript regular expressions with match counts, bounded highlights and capture groups. Cancellable browser Worker with a two-second limit.

  • Runs in your browser
  • Your data never leaves your browser
  • Free · No Sign-Up
Enter a JavaScript regular expression without surrounding slashes. Input and flag changes run after 300 ms. Matching uses a browser Worker with a two-second limit; Cancel stops the current run. A timeout or cancellation gives no complete result.
Find all matches when g is on. Turn it off to return only the first match. Changing this flag starts a new run after 300 ms.
Ignore case when matching. Accents remain significant: cafe with i matches CAFE but not Café.
Let ^ and $ match the start and end of each line. With m off, these anchors refer to the whole text.
Let the dot match line breaks as well as other characters. This does not change the meaning of ^ and $.
Type or paste the text to test. Changes stop the previous run and wait 300 ms before matching again. Ctrl+L (⌘+L on Mac) inside this tool clears both inputs and results while keeping the flags.

Enter a pattern and test text to see highlights and capture groups.

Highlighted Matches The preview shows the first 100,000 UTF-16 units and at most 1,000 highlights. Long text scrolls inside this panel. An invalid pattern shows the text without highlights.
Match details Completed runs count every match. This list shows the first 100 matches and 20 groups per match, numbered even for named groups. Values are limited to 1,000 UTF-16 units each and 100,000 in total; … marks shortening. Indexes also use UTF-16 units.
Examples, details and FAQ Worked examples, how it compares with other tools, and answers to common questions.

Common Regex Patterns

  • \d+ — one or more digits
  • \w+ — one or more word characters (letters, digits, underscore)
  • [a-zA-Z]+ — letters only
  • ^\s+|\s+$ — leading or trailing whitespace
  • (\w+)@(\w+.\w+) — simple email capture
  • https?://\S+ — URLs

Tested Patterns

Each row shows what the tester returns with the g flag on:

PatternTest stringMatches
<.+><a>foo</a><a>foo</a> (greedy: first < to last >)
<.+?><a>foo</a><a>, </a> (lazy)
-?\d+(?:\.\d+)?temp -3.5, max 42-3.5, 42
#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\b#fff #1a73e8 #12345g#fff, #1a73e8
(?<=\$)\d+cost $4242 (lookbehind)
^(?<ts>\S+)\s+(?<level>\w+)\s+(?<msg>.+)$2026-04-07T14:23:01 ERROR connection refused1 match; groups 2026-04-07T14:23:01, ERROR, connection refused

A regex checks the format only. ^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$ accepts 2026-02-31, so parse dates with a date library.

Flags in Practice

The same text gives different results as flags change. With this three-line log as the test string:

ERROR disk full
WARN retry 3
ERROR timeout
  • ^ERROR .+ with only g finds 1 match (ERROR disk full at index 0): ^ means the start of the whole text.
  • Add m and it finds 2 matches, the second at index 29, because ^ now matches after every line break. The index counts the two newline characters too.
  • . never crosses a line break unless s is on: a.b finds nothing in “a”, newline, “b” until you tick s.
  • cafe with i on Café CAFE cafe finds CAFE and cafe but not Café; case-insensitive matching does not ignore accents.

Each match line shows its index, and each capture group is listed under it in order, including groups that did not take part in the match (shown as undefined). There is no Run button: the result updates 0.3 seconds after you stop typing. To try a pattern against a JSON document instead, the JSONPath tester queries by path rather than by text.

Common Mistakes

  • Unescaped metacharacters. . * + ? ( ) [ ] { } ^ $ | \ have special meanings. Write \. to match a dot.
  • ^ and $ in multi-line text. Without the m flag they match only at the start and end of the whole text.
  • \w is ASCII only. \w+ on café 東京 matches only caf. Use a character range such as [\u4e00-\u9fff]+ for Chinese characters.
  • Nested quantifiers. (a+)+$ can take a long time on a near-match. Matching runs in a native JavaScript RegExp Worker with a two-second total limit. Cancel stops it immediately. A timeout or cancellation gives no complete result. Changing the input stops the previous run.

Limits

  • JavaScript syntax only. Python’s (?P<name>...) gives “Invalid group”; use (?<name>...). Patterns written for Go (RE2), PCRE, or .NET can behave differently.
  • Four flags. Only g, i, m, and s are available. There is no u flag, so \p{L} is read as the literal text p{L}, and y, d, and v are not available.
  • Groups are listed by number. Named groups appear as Group 1, Group 2, and so on.
  • Full counts, bounded preview. Completed runs count every match. Highlights cover the first 100,000 UTF-16 units and at most 1,000 matches. The list shows the first 100 matches and 20 groups per match; each value is limited to 1,000 units, with a total value budget of 100,000 units. Shortened values end in …. Indices use UTF-16 units, so an emoji before a match adds 2. Worker support is required.
  • No replace. The tester finds matches; it does not run replace().

FAQ

Which regex flavor does this tool use?

JavaScript (ECMAScript) regex via the browser's built-in RegExp engine.

What flags are supported?

g (global), i (case-insensitive), m (multiline), and s (dotAll — dot matches newline). You can combine them.

Why does 'g' flag matter?

Without 'g', only the first match is returned. With 'g', all matches are found.

Are capture groups shown?

Yes. The list shows the first 100 matches and up to 20 groups per match. Shortened values are marked with … .