Say I have this htmltext "<font face='verdana'><b>hello world</b></font><br><i>abc123<br>hi again world<br></i>"
And it is being appended with other html lines over time, but no two lines are the same, nor is there a pattern of <br>'s being a common separator per 'line'. I want to be able to execute something like myHtmlText=myHtmlText.reduce(10); And have it become something like: "<i>abc123<br>hi again world<br></i>" Seeing as that's the lowest amount closest to 10% reduction it could be trimmed to without breaking the html output when displayed... If it was: "hi again world<br></i>" It wouldn't work as needed.. and would paralyze an htmltext box from showing anymore text from that point forward. Even if just a 50% reduction could be worked out easily.. that'd at least be functional.. Do you see now the dilemma? -Jayson > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:flashcoders- > [EMAIL PROTECTED] On Behalf Of elibol > Sent: Tuesday, January 17, 2006 2:25 PM > To: Flashcoders mailing list > Subject: Re: [Flashcoders] efficient htmltext.reduce() function? > orsimilaridea? > > I hate to impose, but my curiousity is forcing me to question: what is the > reason for html reduction? How does a regular html tag look compared to a > reduced one? What exactly does the algorithm do? > > I apologize for side tracking, I hope you find the answer you're looking > for > Jayson. > > H > > On 1/17/06, Jayson K Hanes <[EMAIL PROTECTED]> wrote: > > > > Thanks gunnar.. I've used regex stuff for simple string manipulation.. > > but I can't see how it could be applied to arbitrarily reduce the length > > of an html string??.. at least.. not without a lot of work? > > > > -Jayson > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] [mailto:flashcoders- > > > [EMAIL PROTECTED] On Behalf Of Gunnar Reinseth > > > Sent: Tuesday, January 17, 2006 4:19 AM > > > To: Flashcoders mailing list > > > Subject: RE: [Flashcoders] efficient htmltext.reduce() function? or > > > similaridea? > > > > > > 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 [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

