Posted By

adrianparr on 02/16/10


Tagged

regex html strip regexp text remove markup as3 htmltext gskinner


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tspitzr


AS3 Remove HTML Tags From Text


 / Published in: ActionScript 3
 

URL: http://www.gskinner.com/RegExr/

Grant Skinner's RegExr: Online Regular Expression Testing Tool is very handy for checking your regular expressions. http://www.gskinner.com/RegExr/

  1. var myString:String = "<p><b>bold</b> <i>italic</i> <a href='#'>link</a> <br>linebreak</p>";
  2. trace(myString)
  3. var removeHtmlRegExp:RegExp = new RegExp("<[^<]+?>", "gi");
  4. myString = myString.replace(removeHtmlRegExp, "");
  5. trace(myString);
  6.  
  7. // OUTPUT
  8. // <p><b>bold</b> <i>italic</i> <a href='#'>link</a> <br>linebreak</p>
  9. // bold italic link linebreak

Report this snippet  

You need to login to post a comment.