remove html tags from text

Ken Ray kray at sonsothunder.com
Fri Sep 8 13:24:39 EDT 2006


On 9/8/06 7:52 AM, "paolo mazza" <paolo.mazza at neol.it> wrote:

> just a simple task for Revolution!
> How can I remove html tags from text?
> 
> i.e.
> from: try  <b> solve<b> this <<httpk.hhkjhlkjlljkl= hkjh> quiz </a>
> to:  try   solve  this   quiz
> 
> I should use a wildcard  but ....
> 
> filter TEXT with "<*>" does not work.  It is only for a list.

Here's what I use... there's two versions - one for "Rev HTML" (i.e. the
version that is generated/managed in Rev):


function stsStripHTML what
  put replaceText(what,"<.*?>","") into noHTML
  return noHTML
end stsStripHTML


and the other is for web pages (because they can contain tags like <script>
<style>, etc. tags that Rev HTML doesn't maintain):


function stsStripHTML what
  put replaceText(what,"(?si)<script.*?/script>","") into what
  put replaceText(what,"(?si)<style.*?/style>","") into what
  put replaceText(what,"<.*?>","") into what
  put replaceText(what,tab,"") into what
  put replaceText(what,CR & "{3,}","") into what
  return what
end stsStripHTML

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list