VSCode always autofixs the Regexp string:
new RegExp("^[0-9\.]+$", "i")
to
new RegExp("^[0-9.]+$", "i")
Does anybody know how to resolve this problem?
VSCode always autofixs the Regexp string:
new RegExp("^[0-9\.]+$", "i")
to
new RegExp("^[0-9.]+$", "i")
Does anybody know how to resolve this problem?
That's perfectly fine - if you want to match a number or a literal dot .
. If you want to match a number, a literal dot, and a literal backslash, you need to escape the backslash:
new RegExp("^[0-9.\\]+$", "i")
You could use String.raw
:
new RegExp(String.raw`^[0-9.\\]+$`, "i")