正则表达式匹配<font>属性

cla*_*oda 0 html c# regex

我有一个字符串,其中包含类似的内容;

"<font color=\"Red\">"
Run Code Online (Sandbox Code Playgroud)

我需要一个能匹配任何颜色的正则表达式.我试过下面的正则表达式没有运气.有人有什么建议吗?

string pattern = "/<font[^>]*>/";
string newTag = Regex.Replace(txt_htmlBody.Text, pattern, "<font color=\"Black\">");
Run Code Online (Sandbox Code Playgroud)

Ibr*_*jar 5

C#中的正则表达式不需要PERL或PHP等模式分隔符,因此您需要将模式更改为:

string pattern = "<font[^>]*>";
                  ^         ^
            Notice the removed / from the expression
Run Code Online (Sandbox Code Playgroud)