1

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`?

4

1 回答 1

3

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

于 2013-06-03T10:09:03.083 回答