A Regular Expression for Stripping HTML Tags

Here’s a regex I wrote yesterday for stripping specific html tags from a string:

<[^>]*(table|tr|td|th)[^<]*>

Here’s an example in AS3 that removes <p> and <b> tags:

var testString:String = “<p><b>Hello</b> world!</p>”;
var regEx:RegExp = new RegExp(“<[^>]*(p|b)[^<]*>”,”gi”)
trace(testString.replace(regEx,”"));

Enjoy.

2 Responses to “A Regular Expression for Stripping HTML Tags”

  1. Jay says:

    Hello
    First of all, sorry to put irrelevant comment to this post. But I had installed SP1 on Bootcamp partition of my MAC and experienced exactly same thing tht you did (you posted about it in 2006)

    I was searching for solutions on google and I came across your old post about similar situation. In the end you mentioned that you formatted the partition to get things right. How did you partition it? I can’t find a way to do so, and I cant login to my leopard account now.

  2. tom says:

    I had to do a complete wipe and reinstall from the OSX disc. Sorry you’re having trouble, and I hope things improve.