我正在比较字符串输入Start和\\\ 例如:
\\\ OR-01
匹配字符串的脚本
var input = '\\\\\\OR-01'
var room = 'OR-01'
var regex = new RegExp('\\\\\\'+room, 'i');
var regexResult = regex.exec(input);
console.log(regexResult); --output is [ '\\OR-01', index: 2, input: '\\\\\\OR-01' ]
但是如果我改变以\ W,\ B,\ N开头的输入我的逻辑不起作用。
var input = '\\\\\\WR-01'
var room = 'WR-01'
var regex = new RegExp('\\\\\\'+room, 'i');
var regexResult = regex.exec(input);
console.log(regexResult); ------output is null.
对于\ W,\ B,\ N可能是其他字符,我也变为空。如何解决这个问题?