javascript - 在具有 Javascript 匹配的字符串中查找插入符号 ^ 字符

标签 javascript regex string match

<分区>

Javascript 中的match 方法会找到^ 插入符吗?

这对我不起作用。

var theString = '^A^B^C^D';
var theMatch = theString.match(/^/g);

插入符号的 ASCII 码是 94,我可以通过 ASCII 码匹配它吗?

最佳答案

^ 是一个特殊字符。你必须逃避它:

var theMatch = theString.match(/\^/g);

关于javascript - 在具有 Javascript 匹配的字符串中查找插入符号 ^ 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23449186/

相关文章:

javascript - Chrome 认为我的 JavaScript 是普通话

Python使用正则表达式匹配具有多个换行符的段落

string - 在 Rust 中将 Vec<String> 转换为 &str 的一部分?

javascript - Lightswitch HTML 客户端 : How to re-render an item (re-execute postRender callback)

Javascript 展平对象内的数组

javascript - 两个输入文本只允许一个提交

java - 删除句子和段落之间的各种额外空格

java - # 个标签的正则表达式

c# - 如果默认字符串为空,为什么我不能使用 String.Contains()?

python - 如何使用字符串引用类的实例?