Regex Tester

Regex Tester test regular expression matches JavaScript regex flags inspect regex capture groups
Regex Tester

Test a browser-compatible expression

Enter a pattern without surrounding slash characters, choose JavaScript flags, add sample text, and select Test expression. Results list each match, its zero-based character position, and any numbered capture groups.

Advertisement

Patterns and flags

The pattern follows the regular-expression implementation in the current browser. Common flags include g for every match, i for case-insensitive matching, m for line-oriented anchors, s for dot matching line breaks, and u for Unicode-aware parsing. The tester adds global matching internally when needed so it can enumerate results.

Worked example

Use the pattern \b([A-Z][a-z]+)\b, the g flag, and the text “Maple and Oak grow here.” The result finds Maple and Oak, reports their starting indexes, and shows each captured word from the parentheses. Add the i flag and lowercase words can satisfy the same letter ranges.

Why engines disagree

JavaScript regex syntax is not identical to PCRE, .NET, Java, Python, RE2, or database implementations. A pattern accepted here may use different named-group syntax, character classes, escaping, flags, or lookaround support elsewhere. Test again in the actual target runtime before shipping a validation rule or log parser.

Empty matches and performance

Some expressions match an empty position. The tester advances manually after such a match to avoid an endless loop and caps output at 1,000 matches. Catastrophic backtracking remains possible with certain nested patterns and hostile input. Keep test samples modest and do not treat a browser experiment as proof that a pattern is safe for untrusted production data.

Privacy and limitations

Patterns and samples remain in the page. The tool does not explain every token, generate application code, benchmark performance, replace text, store shareable links, or emulate other regex engines. Match indexes count JavaScript string positions, which can differ from user-perceived characters for some Unicode sequences.

Regex Tester FAQ

Should I include surrounding slashes?

No. Enter only the pattern; flags have their own field.

Does this use PCRE?

No. It uses the current browser's JavaScript regular-expression engine.

Why was output stopped?

The page caps a run at 1,000 matches to keep the interface manageable.

Related tools

Categories

Tags