I have a string variable that contains an HTML page’s response. It contains hundreds of tags, including the the following three html tags:
<tag1 prefix1314030136543="2">
<tag2 prefix131403013654="1" anotherAttribute="432">
<tag3 prefix13140301376543="4">
I need to be able to strip out any attribute that starts with “prefix” along with its value, regardless of tag name. In the end, I’d like to have:
<tag1>
<tag2 anotherAttribute="432">
<tag3>
I am using C#. I’m assuming RegEx is the solution, but I’m horrible with RegEx and hope someone can help me out here.
Look at Html Agility Pack.
Using regex: