Regex Tester

JavaScript regex syntax, all matches with positions and capture groups. Flags are toggles rather than a string you have to remember.

Matches
—
Match count
—

Worked example

The pattern (\w+)@(\w+\.\w+) against the sample finds two matches, each with the local part and domain as separate capture groups. The index tells you where in the string the match starts, counting from zero.

A regex tester earns its place by showing matches, positions and capture groups at the same time. Seeing only "it matched" does not tell you whether it matched what you meant.

Flags, briefly

g finds all matches rather than the first. i ignores case. m makes ^ and $ match at line boundaries instead of the whole string. s lets . cross newlines — without it, a dot stops at the end of a line.

The zero-width trap

A pattern that can match an empty string, such as a*, loops forever under a global search unless the position is advanced manually. This tester handles that, but the same bug appears constantly in application code.

Syntax differences

This uses JavaScript regex, which differs from PCRE and Python in named groups ((?<name>...)), lookbehind support, and possessive quantifiers. A pattern tested here may need rewriting for a PHP or Java backend.

Escaping

Inside a JavaScript string literal, a backslash needs doubling. In a regex written directly in a page or a /.../ literal, it does not. Half of all "my regex does not work" reports are this.