Eliminar etiquetas HTML de un texto


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



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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.