Regular expression to find any HTML tag with/without attributes

G

Guest

Hi,

I've written the code to read an HTML file into a string. Now I want to
replace tags with other things. The problem comes up that some row tags
(<tr>) are just a plain tag like <tr>, and sometimes they have attributes,
like <tr bgcolor=''>. My code right now looks like:

text = Regex.Replace(text, "<tr*>", "")

What would make this work?
 
K

Ken Tucker [MVP]

Hi,

http://www.regexlib.com/REDetails.aspx?regexp_id=464

Ken
--------------
Hi,

I've written the code to read an HTML file into a string. Now I want to
replace tags with other things. The problem comes up that some row tags
(<tr>) are just a plain tag like <tr>, and sometimes they have attributes,
like <tr bgcolor=''>. My code right now looks like:

text = Regex.Replace(text, "<tr*>", "")

What would make this work?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top