Regex help looking for a name in a string.
Ok, no doubt this is an easy RegEx question, but not for me. I have two queries. One returns a set of names, the other a string which may or may not contain one or more of the names. I want to check for the existence of a name in the string, and if I find it, make it a hyperlink. So far I have this: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop Which works in a limited sense but stumbles where names are similar or contain the same words - for example John Smith John Smith Sons If the string contained John Smith Sons, the code would highlight the John Smith part but not the rest. Any suggestions? Thanks will ~| Create Web Applications With ColdFusion MX7 Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276379 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
Is there a delimited in the list of names (work_string), something that you can include in your reg ex to anchor it to an entire entry? Mark -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 5:27 AM To: CF-Talk Subject: Regex help looking for a name in a string. Ok, no doubt this is an easy RegEx question, but not for me. I have two queries. One returns a set of names, the other a string which may or may not contain one or more of the names. I want to check for the existence of a name in the string, and if I find it, make it a hyperlink. So far I have this: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop Which works in a limited sense but stumbles where names are similar or contain the same words - for example John Smith John Smith Sons If the string contained John Smith Sons, the code would highlight the John Smith part but not the rest. Any suggestions? Thanks will ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276380 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 5:27 AM To: CF-Talk Subject: Regex help looking for a name in a string. Ok, no doubt this is an easy RegEx question, but not for me. I have two queries. One returns a set of names, the other a string which may or may not contain one or more of the names. I want to check for the existence of a name in the string, and if I find it, make it a hyperlink. So far I have this: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop Which works in a limited sense but stumbles where names are similar or contain the same words - for example John Smith John Smith Sons If the string contained John Smith Sons, the code would highlight the John Smith part but not the rest. Any suggestions? Thanks will ~| Create Web Applications With ColdFusion MX7 Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276382 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Regex help looking for a name in a string.
It does really look like your using Regex's. Since you're looking for strings essentially, can't you just use ReplaceNoCase? On 4/27/07, Will Swain [EMAIL PROTECTED] wrote: Ok, no doubt this is an easy RegEx question, but not for me. I have two queries. One returns a set of names, the other a string which may or may not contain one or more of the names. I want to check for the existence of a name in the string, and if I find it, make it a hyperlink. So far I have this: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop Which works in a limited sense but stumbles where names are similar or contain the same words - for example John Smith John Smith Sons If the string contained John Smith Sons, the code would highlight the John Smith part but not the rest. Any suggestions? Thanks will ~| ColdFusion MX7 and Flex 2 Build sales marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276383 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Regex help looking for a name in a string.
that should be It doesn't really look like your using Regex's On 4/27/07, Zaphod Beeblebrox [EMAIL PROTECTED] wrote: It does really look like your using Regex's. Since you're looking for strings essentially, can't you just use ReplaceNoCase? On 4/27/07, Will Swain [EMAIL PROTECTED] wrote: Ok, no doubt this is an easy RegEx question, but not for me. I have two queries. One returns a set of names, the other a string which may or may not contain one or more of the names. I want to check for the existence of a name in the string, and if I find it, make it a hyperlink. So far I have this: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop Which works in a limited sense but stumbles where names are similar or contain the same words - for example John Smith John Smith Sons If the string contained John Smith Sons, the code would highlight the John Smith part but not the rest. Any suggestions? Thanks will ~| Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 Flex 2 Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276384 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Regex help looking for a name in a string.
No, sadly. It's just a field of text, sometimes the entries (names) are seperated by commas, sometimes by new lines, but not everything is a name. A bit of background - basically, this is a text description about an event, and includes the names of the artists performing. I'm trying to implement a function so that the client can add profiles about artists, and if the artist has a profile this is reached by a link to a new window containing more info, an image etc.. For example typical content in the works_string might look like: David Rees-Williams Triobr bA Taste of France: Jazz Transcriptions of the Classics./b But the only part that might need to be transformed to a link would be David Rees-Williams Trio. That's fine, and the code I wrote can do that. However, you might also have a profile for David Rees-Williams, so the code needs to be clever enough to recognise that, and this is where the problem lies. If I was building this from scratch I'd change the way the data is stored, so that each artist was a separate entry in the db, and then it would be an easy task. But I'm not and that's not really an option. Thanks Will -Original Message- From: Gaulin, Mark [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:27 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Is there a delimited in the list of names (work_string), something that you can include in your reg ex to anchor it to an entire entry? Mark -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 5:27 AM To: CF-Talk Subject: Regex help looking for a name in a string. Ok, no doubt this is an easy RegEx question, but not for me. I have two queries. One returns a set of names, the other a string which may or may not contain one or more of the names. I want to check for the existence of a name in the string, and if I find it, make it a hyperlink. So far I have this: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop Which works in a limited sense but stumbles where names are similar or contain the same words - for example John Smith John Smith Sons If the string contained John Smith Sons, the code would highlight the John Smith part but not the rest. Any suggestions? Thanks will ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276385 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Regex help looking for a name in a string.
Are the names delimited by something (like commas) or just strung together? On 4/27/07, Will Swain wrote: Ok, no doubt this is an easy RegEx question, but not for me. I have two queries. One returns a set of names, the other a string which may or may not contain one or more of the names. I want to check for the existence of a name in the string, and if I find it, make it a hyperlink. So far I have this: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop Which works in a limited sense but stumbles where names are similar or contain the same words - for example John Smith John Smith Sons If the string contained John Smith Sons, the code would highlight the John Smith part but not the rest. Any suggestions? Thanks will ~| Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 Flex 2 Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276386 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
Hi James, See my previous reply. They aren't delimited by anything in particular. Thanks. will -Original Message- From: James Holmes [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 14:27 To: CF-Talk Subject: Re: Regex help looking for a name in a string. Are the names delimited by something (like commas) or just strung together? On 4/27/07, Will Swain wrote: Ok, no doubt this is an easy RegEx question, but not for me. I have two queries. One returns a set of names, the other a string which may or may not contain one or more of the names. I want to check for the existence of a name in the string, and if I find it, make it a hyperlink. So far I have this: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop Which works in a limited sense but stumbles where names are similar or contain the same words - for example John Smith John Smith Sons If the string contained John Smith Sons, the code would highlight the John Smith part but not the rest. Any suggestions? Thanks will ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276387 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
Sure. But it still wouldn't work. :) -Original Message- From: Zaphod Beeblebrox [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:56 To: CF-Talk Subject: Re: Regex help looking for a name in a string. It does really look like your using Regex's. Since you're looking for strings essentially, can't you just use ReplaceNoCase? On 4/27/07, Will Swain [EMAIL PROTECTED] wrote: Ok, no doubt this is an easy RegEx question, but not for me. I have two queries. One returns a set of names, the other a string which may or may not contain one or more of the names. I want to check for the existence of a name in the string, and if I find it, make it a hyperlink. So far I have this: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop Which works in a limited sense but stumbles where names are similar or contain the same words - for example John Smith John Smith Sons If the string contained John Smith Sons, the code would highlight the John Smith part but not the rest. Any suggestions? Thanks will ~| Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 Flex 2 Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276388 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
I think this is a good approach too, but it will get complicated because you have to avoid matching text inside an existing already-hyperlinked bit of text. I suspect that this is less of a regex problem and the solution will require searching for strings manually, but at least the solution can be described and wil work, so that's something. Mark -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 8:47 AM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 5:27 AM To: CF-Talk Subject: Regex help looking for a name in a string. Ok, no doubt this is an easy RegEx question, but not for me. I have two queries. One returns a set of names, the other a string which may or may not contain one or more of the names. I want to check for the existence of a name in the string, and if I find it, make it a hyperlink. So far I have this: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop Which works in a limited sense but stumbles where names are similar or contain the same words - for example John Smith John Smith Sons If the string contained John Smith Sons, the code would highlight the John Smith part but not the rest. Any suggestions? Thanks will ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276391 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
Well, I've got a couple of comments, for what they're worth. First, you're not using RegEx. Next, it appears that what you're doing here: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop is you have two queries, one of the event(s), one grabbing a list of artists. Are you sorting the artists? It looks to me like when you loop over the artists, you're simply getting John Smith first. So, you have a statement like change all occurrences of 'John Smith', which it does. On the next pass, your statement reads change all occurrences of 'John Smith Sons', but it doesn't find any. Now, using this method, you could easily run into other problems. Say you sort the artists query to avoid the above. What happens when (reverse alphabetically) you've just replaced some string Smith? Then, when it gets to J, it will fail both John Smith and John Smith Sons. Trying to do this programmatically will be very challenging and you might not like the result. This email message may contain privileged and/or confidential information. If you are not the intended recipient(s), you are hereby notified that any dissemination, distribution, or copying of this email message is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete this email message from your computer. CAUTION: The Agency of Human Services cannot ensure the confidentiality or security of email transmissions. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276393 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
Hi Bobby, Out of interest, how would I reorder by length? In the query? MySQL 4.1.7 Thanks Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:47 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276395 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Regex help looking for a name in a string.
Yes, I'm in agreement. I wondered if a regex was the answer here, but I have no idea. Interestingly, if I reverse the order of the query I still get the same result, which is odd and not what I'd expect. I did a cfdump of the query to check it is ordered correctly. I'm beginning to think an alternative approach might be in order here... -Original Message- From: Leitch, Oblio [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 14:48 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Well, I've got a couple of comments, for what they're worth. First, you're not using RegEx. Next, it appears that what you're doing here: cfset works_string = qry_getEvent.works cfloop query=qry_getProfiles cfset works_string = REReplaceNoCase(#works_string#, #artist#, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, ALL) /cfloop is you have two queries, one of the event(s), one grabbing a list of artists. Are you sorting the artists? It looks to me like when you loop over the artists, you're simply getting John Smith first. So, you have a statement like change all occurrences of 'John Smith', which it does. On the next pass, your statement reads change all occurrences of 'John Smith Sons', but it doesn't find any. Now, using this method, you could easily run into other problems. Say you sort the artists query to avoid the above. What happens when (reverse alphabetically) you've just replaced some string Smith? Then, when it gets to J, it will fail both John Smith and John Smith Sons. Trying to do this programmatically will be very challenging and you might not like the result. This email message may contain privileged and/or confidential information. If you are not the intended recipient(s), you are hereby notified that any dissemination, distribution, or copying of this email message is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete this email message from your computer. CAUTION: The Agency of Human Services cannot ensure the confidentiality or security of email transmissions. ~| Macromedia ColdFusion MX7 Upgrade to MX7 experience time-saving features, more productivity. http://www.adobe.com/products/coldfusion?sdid=RVJW Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276397 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Regex help looking for a name in a string.
Yes, Do it in your query. Try this... Select artist From tablename Order by length(artist) -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 10:24 AM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Hi Bobby, Out of interest, how would I reorder by length? In the query? MySQL 4.1.7 Thanks Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:47 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276423 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Regex help looking for a name in a string.
I dont know what I was thinking but that wont work either. Say you had Bobby and Bobby Hartsfield If you replaced Bobby Hartsfield with a link then Bobby... the code would replace the Bobby within Bobby Hartsfield You will need to order the names by length descending to make sure the longer names are taken care of first but you will also need to use a regular expression to replace the strings only if they are NOT within a.*?(#artist#)/a already -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:15 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Yes, Do it in your query. Try this... Select artist From tablename Order by length(artist) -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 10:24 AM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Hi Bobby, Out of interest, how would I reorder by length? In the query? MySQL 4.1.7 Thanks Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:47 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276431 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
Or a couple loops !--- loop the query and replace the names with markers --- cfloop query=artists cfset thetext = replacenocase(thetext, artist, **#currentrow#**, all) / /cfloop !--- now loop again and replace the placeholders with their links --- cfloop query=artists cfset thetext = replace(thetext, **#currentrow#**, a href='mypage.cfm?var=#artist#'#artist#/a, all) / /cfloop That did the trick for me. -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:34 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. I dont know what I was thinking but that wont work either. Say you had Bobby and Bobby Hartsfield If you replaced Bobby Hartsfield with a link then Bobby... the code would replace the Bobby within Bobby Hartsfield You will need to order the names by length descending to make sure the longer names are taken care of first but you will also need to use a regular expression to replace the strings only if they are NOT within a.*?(#artist#)/a already -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:15 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Yes, Do it in your query. Try this... Select artist From tablename Order by length(artist) -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 10:24 AM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Hi Bobby, Out of interest, how would I reorder by length? In the query? MySQL 4.1.7 Thanks Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:47 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) ~| ColdFusion MX7 by Adobe® Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276435 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Regex help looking for a name in a string.
Good plan. I reckon that will work. Now to play with the regex... Cheers w -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 20:34 To: CF-Talk Subject: RE: Regex help looking for a name in a string. I don't know what I was thinking but that wont work either. Say you had Bobby and Bobby Hartsfield If you replaced Bobby Hartsfield with a link then Bobby... the code would replace the Bobby within Bobby Hartsfield You will need to order the names by length descending to make sure the longer names are taken care of first but you will also need to use a regular expression to replace the strings only if they are NOT within a.*?(#artist#)/a already -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:15 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Yes, Do it in your query. Try this... Select artist From tablename Order by length(artist) -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 10:24 AM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Hi Bobby, Out of interest, how would I reorder by length? In the query? MySQL 4.1.7 Thanks Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:47 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) ~| ColdFusion MX7 and Flex 2 Build sales marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276437 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
That's sweet Bobby - seems to work a treat. Thanks very much. Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 20:43 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Or a couple loops !--- loop the query and replace the names with markers --- cfloop query=artists cfset thetext = replacenocase(thetext, artist, **#currentrow#**, all) / /cfloop !--- now loop again and replace the placeholders with their links --- cfloop query=artists cfset thetext = replace(thetext, **#currentrow#**, a href='mypage.cfm?var=#artist#'#artist#/a, all) / /cfloop That did the trick for me. -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:34 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. I don't know what I was thinking but that wont work either. Say you had Bobby and Bobby Hartsfield If you replaced Bobby Hartsfield with a link then Bobby... the code would replace the Bobby within Bobby Hartsfield You will need to order the names by length descending to make sure the longer names are taken care of first but you will also need to use a regular expression to replace the strings only if they are NOT within a.*?(#artist#)/a already -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:15 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Yes, Do it in your query. Try this... Select artist From tablename Order by length(artist) -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 10:24 AM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Hi Bobby, Out of interest, how would I reorder by length? In the query? MySQL 4.1.7 Thanks Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:47 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) ~| Create Web Applications With ColdFusion MX7 Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276453 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
Sorry, Should have said that you DO still have to: order by length(artist) desc -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:43 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Or a couple loops !--- loop the query and replace the names with markers --- cfloop query=artists cfset thetext = replacenocase(thetext, artist, **#currentrow#**, all) / /cfloop !--- now loop again and replace the placeholders with their links --- cfloop query=artists cfset thetext = replace(thetext, **#currentrow#**, a href='mypage.cfm?var=#artist#'#artist#/a, all) / /cfloop That did the trick for me. -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:34 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. I dont know what I was thinking but that wont work either. Say you had Bobby and Bobby Hartsfield If you replaced Bobby Hartsfield with a link then Bobby... the code would replace the Bobby within Bobby Hartsfield You will need to order the names by length descending to make sure the longer names are taken care of first but you will also need to use a regular expression to replace the strings only if they are NOT within a.*?(#artist#)/a already -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:15 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Yes, Do it in your query. Try this... Select artist From tablename Order by length(artist) -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 10:24 AM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Hi Bobby, Out of interest, how would I reorder by length? In the query? MySQL 4.1.7 Thanks Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:47 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276455 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex help looking for a name in a string.
Thanks Bobby, I owe you a beer. And not just for this but for http://www.acoderslife.com/news/index.cfm?storyid=7 too!! Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 21:21 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Sorry, Should have said that you DO still have to: order by length(artist) desc -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:43 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Or a couple loops !--- loop the query and replace the names with markers --- cfloop query=artists cfset thetext = replacenocase(thetext, artist, **#currentrow#**, all) / /cfloop !--- now loop again and replace the placeholders with their links --- cfloop query=artists cfset thetext = replace(thetext, **#currentrow#**, a href='mypage.cfm?var=#artist#'#artist#/a, all) / /cfloop That did the trick for me. -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:34 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. I don't know what I was thinking but that wont work either. Say you had Bobby and Bobby Hartsfield If you replaced Bobby Hartsfield with a link then Bobby... the code would replace the Bobby within Bobby Hartsfield You will need to order the names by length descending to make sure the longer names are taken care of first but you will also need to use a regular expression to replace the strings only if they are NOT within a.*?(#artist#)/a already -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:15 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Yes, Do it in your query. Try this... Select artist From tablename Order by length(artist) -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 10:24 AM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Hi Bobby, Out of interest, how would I reorder by length? In the query? MySQL 4.1.7 Thanks Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:47 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) ~| ColdFusion MX7 and Flex 2 Build sales marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276458 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Regex help looking for a name in a string.
Haha! Beer may have played a part in that article... oh and I accept the beer. ;-) Cheers! -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 5:01 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Thanks Bobby, I owe you a beer. And not just for this but for http://www.acoderslife.com/news/index.cfm?storyid=7 too!! Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 21:21 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Sorry, Should have said that you DO still have to: order by length(artist) desc -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:43 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Or a couple loops !--- loop the query and replace the names with markers --- cfloop query=artists cfset thetext = replacenocase(thetext, artist, **#currentrow#**, all) / /cfloop !--- now loop again and replace the placeholders with their links --- cfloop query=artists cfset thetext = replace(thetext, **#currentrow#**, a href='mypage.cfm?var=#artist#'#artist#/a, all) / /cfloop That did the trick for me. -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:34 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. I don't know what I was thinking but that wont work either. Say you had Bobby and Bobby Hartsfield If you replaced Bobby Hartsfield with a link then Bobby... the code would replace the Bobby within Bobby Hartsfield You will need to order the names by length descending to make sure the longer names are taken care of first but you will also need to use a regular expression to replace the strings only if they are NOT within a.*?(#artist#)/a already -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 3:15 PM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Yes, Do it in your query. Try this... Select artist From tablename Order by length(artist) -Original Message- From: Will Swain [mailto:[EMAIL PROTECTED] Sent: Friday, April 27, 2007 10:24 AM To: CF-Talk Subject: RE: Regex help looking for a name in a string. Hi Bobby, Out of interest, how would I reorder by length? In the query? MySQL 4.1.7 Thanks Will -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 13:47 To: CF-Talk Subject: RE: Regex help looking for a name in a string. Reorder by length so the longer names come first. Also, I think you only need replace(works_string, artist, a href='profiles.cfm?e=#profileID#' target='artistWin'#artist#/a, all) ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276459 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4