I doubt it's the most efficient way, but a really easy way should be this:
function removeHTMLTags(str:String):String {
var tf:TextField = new TextField();
tf.htmlText = str;
return tf.text;
}
Dan Freiman
nondocs <http://nondocs.blogspot.com>
On 6/4/07, pdflibpilot <[EMAIL PROTECTED]> wrote:
I saw a couple of post about removing all the formatting tags from
htmlText and came up with this solution that uses RegExp.
I am not completely satisfied with the form though it works. If anyone
has any suggestions for improvement or if there is an easier way that
I am missing let me know.
function removeHTMLTags(Str):String{
var matchArr = Str.match(/>[a-zA-Z0-9\/][^<]*</g)
// returns raw text but with a leading '>' and trailing '<'
// then loop to remove the brackets and adds a space to the text
var newStr:String = ""
for each(var matchItem in matchArr){
var mStr = matchItem.substring(1,matchItem.length-1)+" "
newStr += mStr
}
return newStr
}
I had no luck using a replace(regX,"") to try and remove all <xxx>
tags for some reason. Maybe someone can shed some light on that too.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links