AS3 Remove HTML Tags From Text


/ Published in: ActionScript 3
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.