Skip to content

Regex Tester

Type the pattern without the surrounding slashes.

Flags
Matches —
Compiled as
—
Capture groups
—
Characters matched
—
Text length
—

Type a regular expression and some test text, and the tester lists every match with its start index, length and capture groups. For example, [A-Z] run against 'The quick brown fox jumps over the lazy dog. It barked.' finds 2 matches, T at index 0 and I at index 45. Syntax errors are reported as you type.

About this tool

Writing a pattern for form validation, log parsing or a search-and-replace usually takes a few tries, and running the whole program after each edit is slow. This tester compiles your expression with the browser's own JavaScript RegExp engine, so what you see is what JavaScript and Node.js will do. Each match is listed in a table with its position, length and the text captured by each group, and the compiled form with its flags is shown so you can paste it straight into code. The global flag is always on, so every match is found, not just the first. One limit: other engines such as PCRE, Python re or .NET support features JavaScript lacks, like possessive quantifiers, so a pattern that passes here can still differ elsewhere.

How to use it

  1. Enter the pattern

    Type the regular expression without slashes, for example \d{3}-\d{4}.

  2. Pick flags

    Turn on i, m, s or u as needed; the global flag is applied automatically.

  3. Add test text

    Paste the text to search, or open a .txt, .csv or .log file from your device.

  4. Read the matches

    Check the table for each match, its index, length and capture groups.

Examples

Capital letters in a sentence

Regular expression
[A-Z]
Flags
Test text
The quick brown fox jumps over the lazy dog. It barked.

Result Matches: 2
Compiled as: /[A-Z]/g
Capture groups: 0
Characters matched: 2
Text length: 55

  1. Compiled /[A-Z]/g with the JavaScript RegExp engine (g is always on, so every match is found).
  2. Scanned 55 characters and found 2 matches.

The class [A-Z] finds the two capitals, T at index 0 and I at index 45.

ISO dates with capture groups

Regular expression
(\d{4})-(\d{2})-(\d{2})
Flags
Test text
Shipped 2024-03-15, returned 2024-04-02.

Result Matches: 2
Compiled as: /(\d{4})-(\d{2})-(\d{2})/g
Capture groups: 3
Characters matched: 20
Text length: 40

  1. Compiled /(\d{4})-(\d{2})-(\d{2})/g with the JavaScript RegExp engine (g is always on, so every match is found).
  2. Scanned 40 characters and found 2 matches.

Each date matches as a whole and the three groups split out year, month and day.

Case-insensitive search

Regular expression
cat
Flags
i – ignore case
Test text
Cat, CAT, cat and concatenate.

Result Matches: 4
Compiled as: /cat/gi
Capture groups: 0
Characters matched: 12
Text length: 30

  1. Compiled /cat/gi with the JavaScript RegExp engine (g is always on, so every match is found).
  2. Scanned 30 characters and found 4 matches.

With the i flag, cat matches Cat, CAT, cat and the cat inside concatenate.

How it is calculated

matches = every result of RegExp(pattern, 'g' + flags).exec(text), advancing past empty matches

pattern
the regular expression in ECMAScript syntax
flags
i ignore case, m multiline anchors, s dot matches newline, u Unicode mode
index
zero-based position of the first character of a match

The pattern is compiled with the global flag plus the flags you choose. exec() is called repeatedly; each call returns the next match and its groups. When a match is empty, the search position moves forward one character so the loop cannot stall. The first 200 matches are listed; the count covers all of them.

When not to use it

  • For patterns meant for PCRE, Python or .NET that rely on features JavaScript lacks, such as possessive quantifiers.
  • For parsing nested formats like HTML or JSON, where a real parser handles structure that regex cannot.

Common mistakes

  • Typing the surrounding slashes, which then become part of the pattern itself.
  • Forgetting to escape a dot, so it matches any character instead of a literal full stop.
  • Expecting ^ and $ to match at each line without turning on the m flag.

Frequently asked questions

Which regex flavour does this use?

ECMAScript, the engine built into your browser. Results match what JavaScript in a browser or Node.js returns, including lookbehind and named groups in current browsers.

Why is there no g flag to tick?

The global flag is always applied so the table can list every match. Without it, exec() would stop at the first match and the count would never exceed one.

What does an empty match mean?

Patterns such as a* or \b can match zero characters. The tester records the position and moves on by one character, and a warning tells you the pattern can match nothing.

How are capture groups shown?

Each group is listed by number with the text it captured, separated by a bar. A group that did not take part in the match shows (no match), which is common with alternation.

Why does my pattern show an error?

The engine could not compile it, usually because of an unclosed bracket or parenthesis, a quantifier with nothing before it, or an invalid escape in u mode. The engine's own message is shown under the field.

Is my text sent to a server?

No. The pattern is compiled and run in your browser, and neither the pattern nor the text leaves your device or is stored.

Cite this tool

Using this tool in an assignment, article or report? Copy a citation, or a link for your website.

APA

Tools Directory Editorial Team. (2026, October 23). Regex Tester. Tools Directory. Retrieved October 26, 2026, from https://tools.milunir.com/developer-tools/developer-reference/regex-tester/

MLA

Tools Directory Editorial Team. “Regex Tester.” Tools Directory, 23 Oct. 2026, https://tools.milunir.com/developer-tools/developer-reference/regex-tester/. Accessed 26 Oct. 2026.

Chicago

Tools Directory Editorial Team. “Regex Tester.” Tools Directory. Last modified October 23, 2026. Accessed October 26, 2026. https://tools.milunir.com/developer-tools/developer-reference/regex-tester/.

Link<a href="https://tools.milunir.com/developer-tools/developer-reference/regex-tester/">Regex Tester – Tools Directory</a>