views:

113

answers:

1

I have a bit of text

"this is the text want I want to do is replace the text, I have just added another is for good measure"

This is stored as a standard string but I want to turn this into html and add css classes like, in this example wrapping around the word "is";

"this is the text want I want to do is replace the text, I have just added another is for good measure"

Any ideas how I can do this in as3?

+3  A: 

The easiest way would be to use String.replace(). Like this:

var html:String = "This is a test";
html.replace(/is/g, "<b>is</b>");

You will probably want to get a little more advanced than that (notice the problem with case) See the Flex documentation on it here: http://livedocs.adobe.com/flex/3/html/help.html?content=09_Working_with_Strings_09.html

Josh Knauer
Ended up using RegExp but your looks a bit neater.Thanks.
Ross
his is regexp..
jonathanasdf