Regular Expressions problem

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I am trying to turn my html page into text only (except for <a> tags -
links).

I have changed everything except remaining tags.
************************************
// Remove remaining tags like <a>, links, images,
// comments etc - anything thats enclosed inside < >

result = System.Text.RegularExpressions.Regex.Replace(result,
@"<[^>]*>",string.Empty,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
***********************************************

Is there a way to change this to say all tags EXCEPT <a> tags?

Thanks,

Tom
 
I think your Regex should be this: @"<[^aA>].*?>"
but it will replace the </A> tags too

hope it is useful:)
 
Here is the working Regex string:
@"<[^aA>/].*?[^aA]?>|</[^aA]>|</[b-zB-Z0-9].*?>"
 

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

Back
Top