For example: var regVal = '\w ';
How to know if it contains a backslash?
迷茫2017-05-19 10:40:52
/\/.test(regVal);
In addition, your regVal
assignment may not achieve the purpose. The backslashes in the string literal must be escaped:
var regVal = "\w+";