4 chars · 1 line
8 chars · 1 line
4 chars · 1 line
8 chars · 1 line
Regex escaping behavior
A plain . is a wildcard in JavaScript regex syntax. That is why v1.2 matches v1x2. Use \. when the pattern is supposed to contain an actual period such as a version, hostname, or file extension separator. This tool is free to use. No account or payment is required.
Last updated
Outside a character class, . normally matches a single character other than a line terminator. Escaping it changes the token from wildcard behavior to the literal period character.
Escape the version separator so x no longer satisfies the pattern.
v1.2v1\.2Common questions
Because . is a wildcard metacharacter, not a literal period, unless it is escaped.
Inside a character class, dot normally loses its wildcard meaning, but explicit escaping can still make intent easier to read.
A JavaScript string literal may need its own escaping before the regex engine receives the backslash. In this tester, enter the regex pattern directly.
Debugging a specific Regex issue? Browse Regex troubleshooting.