如何在正则表达式中转义 html 代码?
我需要找到字符串
&
在一个字符串中
this is my string & this is another string
我不能为此目的使用 HtmlEncode/Decode,因为我需要使用标签。我想要我只找到公共字符串。
我使用它,例如与“另一个”或“我的”一起工作,但不适用于"&"
.
Regex regularextest = new Regex("\b&\b", options);
string RSTest = "char $& morechar";
string lalala = regularextest.Replace("foo & bar", RSTest);
这非常令人沮丧,因为 google 将字符串替换为 & 或“AND”字样。
提前致谢