使用Javascript匹配在字符串中查找插入符^字符

Ala*_*lls 2 javascript regex string match

matchJavascript中的方法会找到^插入字符吗?

这不适合我.

var theString = '^A^B^C^D';
var theMatch = theString.match(/^/g);
Run Code Online (Sandbox Code Playgroud)

插入符号的ASCII码是94.我可以用ASCII码匹配它吗?

Syn*_*tax 6

^是一个特殊的角色.你必须逃脱它:

var theMatch = theString.match(/\^/g);
Run Code Online (Sandbox Code Playgroud)