Friday, January 18, 2008

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.

Was this post helpful to you? If so, please consider making a small donation to keep this blog going.

8 Comments:

Blogger HollerBee Team said...

This comment has been removed by the author.

8:08 PM  
Blogger HollerBee Team said...

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.

8:10 PM  
Blogger tom said...

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

2:03 PM  
Anonymous Anonymous said...

This comment has been removed by a blog administrator.

1:51 AM  
Anonymous Anonymous said...

ralph lauren poloburberry polo shirtthe north face jacketcolumbia jacketspyder jacketed hardy clothing ed hardy clothesed hardy shirts ed hardy t-shirts ed hardy sunglasses ed hardy mensed hardy womens Wholesale HandbagsCheap HandbagsWomens HandbagsCheap PursesDesigner HandbagsTennis RacquetTennis Racket
cheap tennis racquet
tennis racquet discount
cheap tennis racket
discount Tennis Rackethead junior tennis racketwilson tennis racquet
wilson tennis racket
head tennis racketbabolat tennis racket

2:00 AM  
Anonymous Anonymous said...

Do not mean bad.Thank you so much!I just want to show some fashion things to all of you.I like ugg boots.black ugg boots,Loose T-shirt or super-size clothing are the best partners, it allows you to exercise in relax.The classic style cheap uggs may fit someone.You should never design yourself into a monster of no golden section point because beautiful cheap ugg boots.Also,for ladies, in winter sheepskin boots are the excellent choice.ugg boots on sale

3:15 AM  
Anonymous Anonymous said...

Men's polo shirts was the shirt of choice for diverse groups of teenagers
Brightly coloured polo shirts can make you look like a Day-glo dirigible.
Wonderful!You can find the father who desire fashionable eg,uggs fashion,you can enjoy uggs online here, intellectual polo shirt simultaneously

3:15 AM  
Anonymous Anonymous said...

God bless you!I really agree with your opinions.Also,there are some new fashion things here,gillette razor blades.gillette mach3 razor bladesfor men.As for ladies,gillette venus razor blades must the best gift for you in summer,gillette fusion blades are all the best choice for you.

3:16 AM  

Post a Comment

<< Home