[thelist] regex for highlighting search terms in coldfusion

Joshua Olson joshua at waetech.com
Fri Jan 27 13:28:01 CST 2006


> -----Original Message-----
> From: Sarah Adams
> Sent: Friday, January 27, 2006 1:28 PM
> 
> I'm trying to write a ColdFusion script that will highlight 
> search terms within a string. It works great unless there 
> are HTML tags in the string and the search terms appears 
> inside one of the tags. My basic highlighting replace function 
> looks like this:
> 
> <cfset hi = 
> ReplaceNoCase(str,"#term#","<strong>#term#</strong>","all")>
> 
> Can someone tell me how to change this to a ReplaceRENoCase that will 
> not replace "term" if it is between "<" and ">"? I've tried 
> Googling to no avail.

Sarah,

Solving this riddle involves having a really good regex for tags.
Thankfully, I've got just the nugget for you:

http://concepts.waetech.com/replace_inner_text/

<><><><><><><><><><>
Joshua L. Olson
WAE Tech Inc.
http://www.waetech.com/
Phone: 706.210.0168 
Fax: 413.812.4864

Monitor bandwidth usage on IIS6 in real-time:
http://www.waetech.com/services/iisbm/





More information about the thelist mailing list