Ramesh
Ramesh

Reputation: 1252

How to convert Html text into normal plain text?

I have html text which is coming from backend and i need to convert it into normal text to show up in TextArea.

Is there any way to convert Html text into normal plaintext by usingFlex framework`?

Upvotes: 1

Views: 1428

Answers (1)

David Jashi
David Jashi

Reputation: 4511

You will have to use Regexp to remove tags.

From here:

var myString:String = "<p><b>bold</b> <i>italic</i> <a href='#'>link</a> <br>linebreak</p>";
trace(myString)
var removeHtmlRegExp:RegExp = new RegExp("<[^<]+?>", "gi");
myString = myString.replace(removeHtmlRegExp, "");
trace(myString);

// OUTPUT
// <p><b>bold</b> <i>italic</i> <a href='#'>link</a> <br>linebreak</p>
// bold italic link linebreak

In case I got you wrong and you want to display HTML tags in textarea, use escape() function

Upvotes: 3

Related Questions