为何正则匹配捕获不了“\”反斜杠?

var str = "\abc";// 字符串是获取到的,不能更改为了\\abc
var re = /^\abc/;
console.log(re.test(str));//true
console.log(str.match(re));
//["abc", index: 0, input: "abc"] 没有'\'
console.log(re.exec(str));
//["abc", index: 0, input: "abc"] 没有'\'


var re2 = /^\\abc/;
console.log(re2.test(str));//false
console.log(str.match(re2));//null
console.log(re2.exec(str));//null

var re3 = /^\\\abc/;
console.log(re3.test(str));//false
console.log(str.match(re3));//null
console.log(re3.exec(str));//null

var re4 = /^\\\\abc/;
console.log(re4.test(str));//false
console.log(str.match(re4));//null
console.log(re4.exec(str));//null
查看回复