Skip to content
JS
JavaScript error

SyntaxError

The JavaScript exception "invalid range in character class" occurs when a character class in a regular expression uses a range, but the start of the range is greater than the end.

Reference entryJavaScriptFetched
SyntaxError: Invalid regular expression: /[2-1]/: Range out of order in character class (V8-based)
As listed by MDN Web Docs
SyntaxError: invalid range in character class (Firefox)
As listed by MDN Web Docs
SyntaxError: Invalid regular expression: range out of order in character class (Safari)
As listed by MDN Web Docs
Category
SyntaxError
Severity
error
Runtime
both
or press Cmd/Ctrl + Enter. The text is only sent to this site to match it.
Source: MDN Web Docs. Data fetched 2026-09-25T01:48:37.274Z.