Posted By

adrianparr on 02/16/10


regex html strip regexp text remove markup as3 htmltext gskinner

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


AS3 Remove HTML Tags From Text

 / Published in: ActionScript 3


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

  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);
  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.