clamchoda
clamchoda

Reputation: 4971

Regular expression to match <font> attribute

I have a string which contains something like;

"<font color=\"Red\">"

I need a regular expression which will match on any color. I have tried the below regular expression with no luck. Does anyone have some suggestions?

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

Upvotes: 0

Views: 547

Answers (1)

Ibrahim Najjar
Ibrahim Najjar

Reputation: 19423

Regular expressions in C# don't need pattern delimiters like PERL or PHP, so you need to change the pattern to:

string pattern = "<font[^>]*>";
                  ^         ^
            Notice the removed / from the expression

Upvotes: 6

Related Questions