Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含类似内容的字符串;
"<font color=\"Red\">"
我需要一个匹配任何颜色的正则表达式。我试过下面的正则表达式没有运气。有人有什么建议吗?
string pattern = "/<font[^>]*>/"; string newTag = Regex.Replace(txt_htmlBody.Text, pattern, "<font color=\"Black\">");
C# 中的正则表达式不需要像 PERL 或 PHP 这样的模式分隔符,因此您需要将模式更改为:
string pattern = "<font[^>]*>"; ^ ^ Notice the removed / from the expression