var STRIP_PHN_REG_EX = /[\x\X\(\)\.\-\s\',]/g;
Visual Studio gives the following not-very-detailed warning: "Syntax error in regular expression"
However, the regular expression runs fine. What am I missing here?
\\x
and \\X
are not valid here. \\x
can be used with two hexadecimal digits to identify a specific character — for example, \\x09
means the tab character ( \\t
) — but you're not using it that way here; and \\X
has no uses in JavaScript regexes.
But since I can't tell what you want the regex to do, I can't tell you how to fix it. Maybe you just meant
var STRIP_PHN_REG_EX = /[xX().\-\s',]/g;
? (That matches any whitespace character, as well as any of x
, X
, (
, )
, .
, -
, '
, ,
.)
Edited to add: Or maybe by \\x
and \\X
you meant "lowercase hex digit" and "uppercase hex digit", respectively? There's no special syntax for that in JavaScript, but you can write:
var STRIP_PHN_REG_EX = /[0-9a-fA-F().\-\s',]/g;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.