Check a JavaScript regular expression

CodeMoment · Updated 2026-11-08

A JavaScript regular expression is valid when new RegExp accepts the pattern. Validity does not mean the pattern finds the text you care about. (\d+) is valid. In Order 42 it matches 42. In none it matches nothing. Both results are a finished check.

The Regex Tester runs that check in the browser. The pattern and the text stay in the tab. Nothing is uploaded. The page checks JavaScript only. It does not run Python, PCRE, or a database dialect. A construct those engines accept can be a syntax error here, and a JavaScript pattern can be rejected by them.

g lists every match. i ignores case. m makes ^ and $ apply to each line. s lets . match a line break. u is Unicode mode and v is Unicode sets. Use one of those two, not both. y is sticky: the match has to start at the current index, and this page starts that index at 0.

Parentheses store a group. The result shows the group's text and the start and end positions. A name goes in the opening parenthesis, after a question mark. Replace follows String.prototype.replace. $1 is the first stored group. A named group is inserted with a dollar sign and that name. The match list and the replacement come from the same engine.

(a+)+ against a long run of the letter a can backtrack long enough to freeze a tab. The tester stops the search after one second and starts a fresh worker. a* can match an empty string. The search then moves one character forward, or one code point when Unicode mode is on, so it does not stay on the same index.

Read the validity line to see whether JavaScript accepted the pattern. Read the match list to see what it found.