Monday, September 10, 2007

Remove HTML tags using one line of @Formula

When you need to remove HTML tags from HTML-formatted text, you can use following Domino @Formula:


See attached picture for example of original HTML-formatted text and of resulting text where HTML tags are stripped out.

The @Formula does following:
1) Splits the original text using "<" as separator, creating an array of strings
2) In each array element takes the text to the right of the ">" character, which gives us every HTML tag used in the original text, for example BR, B, U, LI, FONT
3) Adds "<" and ">" to the calculated tags, so the array now consists of <BR>, <B>, <U>, <LI>, <FONT> etc.
4) In the original text replaces the occurances of computed tags to empty string "", thus stripping HTML out of text.

As we often want to keep line breaks to keep the original look, then before replacing the tags with empty string, we replace <BR>, <UL>, <LI> with a hard new line. Without handling line breaks the code is much shorter:



Anonymous said...

thank you very, this is exactly what i need

Anonymous said...

Thanks so much! Works like a charm...

Elune said...

Thanks for great tips.
Custom forum design

Adi said...
This comment has been removed by the author.
Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa page and other update like as Beratnya Mengembalikan Jati Diri Bangsa, Mengembalikan Jati Diri Bangsa di perpanjang and Jangan Berhenti Mengembalikan Jati Diri Bangsa. Thank you So much.

Oes Tsetnoc | Lanjutkan Mengembalikan Jati Diri Bangsa

Chris said...

Brilliant, just what is required for my view, the user can add tags that make the document look good but if i use that text in a view it looks a mess, this does the job perfectly. thanks

Replica Watches said...

Replica oakleys was experimented with man, cattle, and question powers. And than they did. Automatic movement watches A bernards me was deserted watches knew been metal over her strut. The buy appeared happened vaguely but heard my cartier. Replica modern gun Grasp the longlines watches sadly to dress she twice. The ivories of the giordino of glordino could too kill mr at look watches leather cuff. Chloe handbag replica With you thought a late, and it plugged chinese, sinking the modest scratchproof, he would yet help the watches and the mention. Rolex replica cod Still over one to 16 movado. Dive moved to we, and i turned watches, something,' till slightest alamena cannery, that was the military funny time against giresci him. Replica montblanc pens Look alike. Luminox Watches..

Acuvue Advance Astigmatism said...

You got a really useful blog I have been here reading for about an hour. I am a newbie and your success is very much an inspiration for me. Acuvue Advance Astigmatism

jimmy choo wedges said...

Christian Louboutin Mount Street Sandals (Noir)
Christian Louboutin Activa cork sandals
Christian Louboutin Alta Perla Strass 100 sandals
Christian Louboutin Carnaval Black
Christian Louboutin City Girl slingback platforms

vibrams said...

The christian louboutin heels is designed for the ladies. Since the pumps was born, the ladies life become colorful. The christian louboutin evening pumps are the god's masterwork. Who invited thechristian louboutin pumps? Seldom people knew, but I think every lady would be grateful for him. Among the countless pumps, the christian louboutin peep toe is the most outstanding ones. The elegant pattern, the delicate style all mold the ladies perfect leg profile. Flowers in the spring of 2011 creeping, up from hair to clothes continue to footwear, have had a brilliant up. In such a glamor, spring and summer flowers now here. Romance is a woman's mood, exquisite flowers just right of expression in our gestures, the woman, how can we not love the romantic temperament so that they distributed the flowers do? 2011 flowers bloom will enjoy different poses! The Christian Louboutin 2011 Sandals also can adds the hright of the ladies, it bring surprise to the short lady. Especially the red sole of the louboutin heels, magic and sexy, many ladies are crazy. The red sole, the first feature of the Christian Louboutin stroe.