Strip HTML using Lotus @Formula

I put together an @Formula that will strip HTML from a string (or string list). It will also conditionally strip out orphan (“<” & “>”) tags. Full writeup is on my site at: http://www.devinolson.net/devin/spankysplace.nsf/plinks/BDOZ-6B8UA7

Here is the code:

REM {Set the behavior};

vStripOrphans := @True;

REM {Use the @Text function in the event that the source field is Rich Text};

REM {This is NEW functionality for Release 6};

vCurrent := @Text(My_Source_Field_Name);

REM {Strip out all valid tags};

vCurrent := @Transform(vCurrent; “vElement”;

@Do(

vTemp := vElement;

@DoWhile(

vTag := @Right(vTemp; “<”);

vTag := @Left(vTag; “>”);

vTemp := @If(vTag = “”; vTemp; @ReplaceSubstring(vTemp; “<” + vTag + “>”; “”));

vTag != “”

);

vElement := vTemp

)

);

REM {If not stripping out orphans, return the current value};

@If(vStripOrphans; “”; @Return(vCurrent));

REM {Strip out Orphans (< & >)};

vCurrent := @Transform(vCurrent; “vElement”;

vElement := @ReplaceSubstring(vElement; “<”:“>”; “”:“”)

);

REM {now return tne current value};

vCurrent;

Hope this helps!

-Devin.