Skip to content
JS
JavaScript error

SyntaxError

The JavaScript exception "\ at end of pattern" occurs when a regular expression pattern ends with an unescaped backslash (\). In a regex literal, the backslash would cause the closing slash / to be a literal character, so this can only appear when using the RegExp() constructor.

Reference entryJavaScriptFetched
SyntaxError: Invalid regular expression: /\/: \ at end of pattern (V8-based)
As listed by MDN Web Docs
SyntaxError: \ at end of pattern (Firefox)
As listed by MDN Web Docs
SyntaxError: Invalid regular expression: \ at end of pattern (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.