Re: Replace Question
This is a case for Regular Expressions (RegEx): REReplaceNoCase(answer, '(#search_string#)', 'span class=keyword\1/span', 'all')# Heh, just seen this after the other thread, so guess I'll repeat what I said there: Using parentheses is completely unnecessary. Use \0 in the replacement string instead. If search_string is (for example) $10 or :) or a+b^c or whatever then simply using it as a regex_pattern will cause problems. To solve this means escaping the meta-characters, for example, search_string.replaceAll('[$^*()+\[\]{}.?\\|]','\\$0') Putting both those together results in: REReplaceNoCase ( answer , search_string.replaceAll('[$^*()+\[\]{}.?\\|]','\\$0') , 'span class=keyword\0/span' , 'all' ) (Though of course, as noted in the other thread, this doesn't deal with HTML.) ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351787 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Replace Question
I have a search results pages and I'd like to highlight the search term to show the matches. Of course, search is not case sensitive. On the results I can do something like: Better written results: #ReplaceNoCase(answer, search_string,span class=keyword search_string /span,all)# This puts a nice little highlight around the search term and makes it easy to see in the results, but it may change the case. For example, if I search for mick jagger and it finds Mick Jagger, my answer come out like: ... and a mick jagger was guy with big lips who dreamed of being a Beatle... Is there a way I could do the replace to highlight the result and NOT change the case? Thanks, Robert Robert Harrison Director of Interactive Services Austin Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austin_ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351739 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace Question
This is a case for Regular Expressions (RegEx): REReplaceNoCase(answer, '(#search_string#)', 'span class=keyword\1/span', 'all')# 1. Search the content of the variable answer 2. Look for the content of the variable search_string 2a. Because parenthesis are being used and we're doing RegEx, the matched text will be 'captured' for later use. The parenthesis are special characters, not part of what is being matched. 3. Replace the matched content with: span class=keyword\1/span 3a. take the captured text from the match and place it within the span block in place of the \1 \1 will contain the exact text matched with whatever case it had rather than the case of the search_string On Wed, Jun 27, 2012 at 2:25 PM, Robert Harrison rob...@austin-williams.com wrote: I have a search results pages and I'd like to highlight the search term to show the matches. Of course, search is not case sensitive. On the results I can do something like: ReplaceNoCase(answer, search_string,span class=keyword#search_string#/span,all)# This puts a nice little highlight around the search term and makes it easy to see in the results, but it may change the case. For example, if I search for mick jagger and it finds Mick Jagger, my answer come out like: ... and a mick jagger was guy with big lips who dreamed of being a Beatle... Is there a way I could do the replace to highlight the result and NOT change the case? Thanks, Robert Robert Harrison Director of Interactive Services Austin Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austin_ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351740 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Replace Question
# REReplaceNoCase(answer, '(#search_string#)', 'span class=keyword\1/span', 'all')# Nice. Works perfectly. Thank You... just waiting for someone to complain about the nested ##'s though LOL :-) Robert Harrison Director of Interactive Services Austin Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austin_ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351741 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace Question
Stop nesting #s!! You're needlessly killing kittens!!! :D #reReplaceNoCase( answer, search_string, 'span class=keyword\1/span', 'all' )# ;-) On Wed, Jun 27, 2012 at 1:51 PM, Robert Harrison rob...@austin-williams.com wrote: # REReplaceNoCase(answer, '(#search_string#)', 'span class=keyword\1/span', 'all')# Nice. Works perfectly. Thank You... just waiting for someone to complain about the nested ##'s though LOL :-) Robert Harrison Director of Interactive Services Austin Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austin_ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351742 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace Question
On Wed, Jun 27, 2012 at 2:51 PM, Robert Harrison rob...@austin-williams.com wrote: # REReplaceNoCase(answer, '(#search_string#)', 'span class=keyword\1/span', 'all')# Nice. Works perfectly. Thank You... just waiting for someone to complain about the nested ##'s though LOL :-) '(' search_string ')' I drop all attempts at being anal about #s when I'm working with RegEx. RegEx is anal enough. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351743 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Replace Question
Stop nesting #s. You're needlessly killing kittens!!! I was sooo waiting for that shoe to drop :-) Robert Harrison Director of Interactive Services Austin Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austin_ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351744 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Replace Question
I hope you noticed that I posted that _because_ you said you were waiting on it. ;-) On Wed, Jun 27, 2012 at 2:08 PM, Robert Harrison rob...@austin-williams.com wrote: Stop nesting #s. You're needlessly killing kittens!!! I was sooo waiting for that shoe to drop :-) Robert Harrison Director of Interactive Services Austin Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austin_ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351745 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Replace Question
Got it. Robert Harrison Director of Interactive Services Austin Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austin_williams -Original Message- From: Matt Quackenbush [mailto:quackfu...@gmail.com] Sent: Wednesday, June 27, 2012 3:37 PM To: cf-talk Subject: Re: Replace Question I hope you noticed that I posted that _because_ you said you were waiting on it. ;-) On Wed, Jun 27, 2012 at 2:08 PM, Robert Harrison rob...@austin-williams.com wrote: Stop nesting #s. You're needlessly killing kittens!!! I was sooo waiting for that shoe to drop :-) Robert Harrison Director of Interactive Services Austin Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austin_ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351746 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Replace Question: Part II
# REReplaceNoCase(answer, '(#search_string#)', 'span class=keyword\1/span', 'all')# This works so wonderfully, I hate to ask a follow-up question, but I have to. Is there a way I can apply this everywhere EXCEPT when the matching content is in an HTML tag (like an HREF tag)? Sorry, but this level of Regex is a bit over my regex skill level. Robert Harrison Director of Interactive Services Austin Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austin_wi ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351747 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Replace Question
Is there something in your CSS that is changing it to lower case? Eric Roberts Owner/Developer Three Ravens Consulting ow...@threeravensconsulting.com http://www.threeravensconsulting.com tel: 630-881-1515 -Original Message- From: Robert Harrison [mailto:rob...@austin-williams.com] Sent: Wednesday, June 27, 2012 1:30 PM To: cf-talk Subject: RE: Replace Question I have a search results pages and I'd like to highlight the search term to show the matches. Of course, search is not case sensitive. On the results I can do something like: Better written results: #ReplaceNoCase(answer, search_string,span class=keyword search_string /span,all)# This puts a nice little highlight around the search term and makes it easy to see in the results, but it may change the case. For example, if I search for mick jagger and it finds Mick Jagger, my answer come out like: ... and a mick jagger was guy with big lips who dreamed of being a Beatle... Is there a way I could do the replace to highlight the result and NOT change the case? Thanks, Robert Robert Harrison Director of Interactive Services Austin Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austin_ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351748 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm