I am using regular expressions to replace any formatting within span tags using the following expression and it works.
retValue = System.Text.RegularExpressions.Regex.Replace(retValue, @"<span[^>]*>", "<span>");
Now, I would like to replace any formatting within the span tags except for 'Underline'. For example in the following string, I would like to remove the formatting within the second span tag, but keep the formatting of the first span tag.
string retValue = "<p><span style=\"text-decoration: underline;\">Test Underline</span></P><p><span style="color:blue">blue</span></p>";
So my retValue should be :
retValue = "<p><span style=\"text-decoration: underline;\">Test Underline</span></P><p><span>blue</span></p>";
I tried using the following expression, but it doesn't replace anything at all. I am trying to understand what is wrong with this code and how can I achieve the expected result.
retValue = System.Text.RegularExpressions.Regex.Replace(retValue, @"<span[^style=\""text-decoration:underline;>]*>", "<span>");