I’m exporting using an HTMLTable in ASP.NET using Response.Write to write all the HTML Table Code to an Excel file.
What I need to do now, is to remove all the Hyperlinks from this Excel file. Is there a better way to do this than to use a Regex?
If a Regex is the best way, how can I just eliminate the tags and not the ID in between?
<td class="header">Details ID</td>
<td>
<div class="id"><a class="details" href="details?id=1232" target="_blank">1232</a></div>
</td>
<td>
<div class="id"><a class="details" href="details?id=1233" target="_blank">1233</a></div>
</td>
<td>
<div class="id"><a class="details" href="details?id=1234" target="_blank">1234</a></div>
</td>
</tr>
This simple regex will do it:
Here’s a link to test it with your input:
http://regexhero.net/tester/?id=c1458e14-de87-4f57-9850-3ee00e573566
If you don’t like parsing HTML with Regex as John Saunders, you can use HtmlAgilityPack: