Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing tagged items from a query

Status
Not open for further replies.

felixtkatt

Programmer
May 14, 2001
18
US
I have a query that pulls a paragraph of HTML text from a database field. In that text there are italicized and bolded elements that I would like to have removed before I display the text on the page.

1. Would it be better/easier/classier to do this in CF or JavaScript?

2. How would I go about doing this? I'm sure string functions would work somehow, but I have no idea of how to best implement them.

Thank you,
FelixTKatt
 
Hey felixtkatt,

I think both languages have some good string handling functions but I think you'll find much more flexibility in CF as well as the fact that it runs on the server so you're guaranteed for it to work. With JS, you're dependent on the visitor's browser to run the js wihout errors and using the assumption that JS is enabled.

I would recommend looking at the replace function along these lines:

<cfset myText=replace(replace(myText,&quot;<b>&quot;,&quot;&quot;,&quot;all&quot;),&quot;</b>&quot;,&quot;&quot;,&quot;all&quot;)>

This should strip out any <b> .. </b> sections. You could then run it through a few others to strip out other tags.

Hope this helps,
GJ
 
I'm assuming that the solution you proposed will rip out the tags, not the text between them.

But that's ok! I realized (read as: &quot;was told&quot;) that if the bolds are replaced with comment tags, that will get rid of any of the text I wanted to rip in the first place.

Thanks for all your help,
FelixTKatt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top