I have a HTML string that I just want the text from:
string html = "<span class="MyText" id="1"> SomeText blah blah</span>";
So I use the following expression:
public static string StripHTMLTags(string source)
{
return Regex.Replace(source, "<.*?>", string.Empty);
}
But sometimes the HTML string contains several lines of HTML:
string html = "<span class="MyText" id="1">SomeText blah blah</span<br><span class="MyText" id="2">SomeText blah blah 1</span><br><span class="MyText" id="2">SomeText blah blah2</span>";
So now I want to extract out the text that is between the <span>
tags and store them in a list or array or lines.
NOTE: I am parsing custom HTML that will only have two tags the break and span tags.
How can I do this using Regex?
and – Harry Boy Sep 06 '16 at 11:25