I am trying to remove HTML style tags from my Crystal report text. I have data like the below:
<span style="font-size:small;">hello world</span><span style="font-size:12.0pt;line-height:115%;">hello again world</span><p style="text-decoration:underline;">hello once again</p>
I want the result to be:
<span>hello world</span><span>hello again world</span><p>hello once again</p>
I've used:
replace({IncidentNarrative.text},ExtractString(Totext({IncidentNarrative.text}),"<span ",">"),"")
replace({IncidentNarrative.text},ExtractString(Totext({IncidentNarrative.text}),"<p ",">"),"")
But this will only remove the first instance of the span
or p
. It does not look for all instances of the span
or p
. I've tried FOR loops and extracting the sub-strings into arrays, but always run into problems.
The following formula looks for the term style=
and removes it and everything between style=
to the next occurence of >
:
StringVar output := {IncidentNarrative.text};
While InStr(output, " style=")>0 And InStr(InStr(output, " style=")+7, output, ">")>0 Do
(
output := Left(output, InStr(output, " style=")-1) &
Mid(output, InStr(InStr(output, " style=")+7, output, ">"))
);
output;