remove html tags from text

Richard Gaskin ambassador at fourthworld.com
Fri Sep 8 12:18:03 CDT 2006


Mark Wieder wrote:

>> function striptags tHtml
>>    replace cr with empty in tHtml -- in case of multi-line tags
> 
>>    replace "<" with cr & "<" in tHtml
>>    replace ">" with ">" & cr in tHtml
> 
>>    filter tHtml without "*<*"
>>    filter tHtml without "*>*"
> 
>>    return tHtml
>> end striptags
> 
> Clever... but it'll fail on
> 
> if xyz > 4096 then
> 
> maybe replace the two filter lines with
> 
>    filter tHtml without "<*>"

This is a very interesting topic.

Being a lazy person, historically I've let the engine do the work by 
setting the htmlText of a field and then getting that field's text.

But given the overhead of field access, that might not benchmark as well 
as doing it in a variable as described here.

Are there any downsides to this approach?  For example, how does it 
account for "<" and ">" which may appear in quoted strings or comments?

--
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com



More information about the use-livecode mailing list