You should definetly be looking into regular expressions. The following could be wrapped up in a utility class and help build your method:
var regex:RegExp = /<.*?>.*?<\/.*?>/g; var str:String = myHtmlTextBox.text; // or wherever you get your source text var result:Object = regexp.exec(str); while(result != null) { trace(result.index + ", " + result); // Place the result in a new string or array and do whatever // processing you'd like result = regex.exec(str); } Useful info: http://www.regular-expressions.info http://livedocs.macromedia.com/labs/1/flex/langref/RegExp.html cheers, gunnar -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jayson K Hanes Sent: 17. januar 2006 01:54 To: Flashcoders mailing list Subject: [Flashcoders] efficient htmltext.reduce() function? or similar idea? Does anyone have any divine wisdom for safely and efficiently "reducing" an htmltext string down in size? I've been using old code for a while that simply loops looking for html tags.. and if it's a known "paired" tag set (like font), looks for the closing tag, and then, substring's from that point onward (thus removing everything ahead of the last complete tag set), and effectively reducing the overall size of the htmltext so that it doesn't forever build in size, and in turn bring flash to its knees if the string gets too long. The problem with this is its slow... and risky.. sometimes.. it fails to match a paired set.. and the output into the flash textbox breaks -- that is -- no more appended text will be seen from that point onward.. and the box appears "Dead" because of broken tags. Ideally for me at least.. a function could be called such as: myHtmlTextBox=myHtmlTextBox.reduce(10); whereby 10 is used such that the result has about 90% remaining (which is obviously a challenge because of the variable lengths of tag groupings among formatted html..) Any ideas? This is a hard topic to google and search the archives with.. Thanks! -Jayson _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders