Skip to content

Regex Tester

Test a JavaScript regular expression on your own text and list every match with its position and capture groups.

Regex tester
Type a pattern, pick flags, paste the test text.

Without the slashes, for example (\d+)-(\d+)

Matches
2
Matches, positions and groups
1: "[email protected]" at index 9
    group 1: "ana"
    group 2: "mailbox"
2: "[email protected]" at index 28
    group 1: "BEN"
    group 2: "sample"

Private: Everything runs in this page. Nothing you type is sent anywhere or saved.

On this page
  1. Regex examples
  2. Formula
  3. How the regex tester works
  4. What this tool does not do
  5. Frequently asked questions
  6. References
  7. Related tools

Regex examples

Pattern, flagsTextMatches
\d+ ga1b22c333"1"@1, "22"@3, "333"@6
^b ma | b | b"b"@2
cat giCat cat CAT"Cat"@0, "cat"@4, "CAT"@8
a* gbaa""@0, "aa"@1, ""@3
(\w+)@(\w+) (none)x@y z@w"x@y"@0

Formula

match = text found by the pattern; index = position of its first character, counting from 0

How the regex tester works

  1. Step oneType the pattern without the slashes at each end.
  2. Step twoTick the flags you need. g finds every match, not just the first.
  3. Step threePaste the test text and read the matches, their positions and the capture groups.

What this tool does not do

  • It uses your browser's JavaScript engine, so a pattern that works here may behave differently in Python, PHP or Java.
  • A pattern with heavy backtracking, such as (a+)+, is stopped after 1.5 seconds with a message, so the page stays usable.
  • A browser that cannot run background workers checks only the first 1,000 characters and says so.
  • It lists at most 200 matches, though it counts more.

Frequently asked questions

Which regular expression flavor is this?

The one built into your browser: JavaScript (ECMAScript). Other languages differ in small details, such as named groups and lookbehind.

Why does a* give an empty match?

A pattern that can match nothing matches the empty text at positions where no a is found. The list shows those empty matches with their index.

What do the flags mean?

g all matches, i ignore case, m ^ and $ work on every line, s the dot also matches a line break, u treat the text as Unicode.

References