Great... thanks a lot, buddy. On 8/3/05, Ewok <[EMAIL PROTECTED]> wrote: > Sorry. I was going with your sample data. They all only had 2 dashes. This > will work as well. > > <cfset tmp = arraynew(1)> > > <cfset tmp[1] = "Adi5RT-F-l-o-12Roy-3(Lg)"> > <cfset tmp[2] = "Adi5RT-FSU2R-ed-2(Md)"> > <cfset tmp[3] = "Adi5RT-FSU---2Red-3(Lg)"> > <cfset tmp[4] = "Adi5RT-FSU2-Red-4(XL)"> > <cfset tmp[5] = "Adi5RT-F------S-----U2Red-5(2X)"> > <cfset tmp[6] = "Adi5RT-FSU-3Wht-2(Md)"> > <cfset tmp[7] = "Adi5RTFSU3Wht-3(Lg)"> > > > <cfloop from="1" to="#arraylen(tmp)#" index="i"> > > <cfset var1 = listdeleteat(tmp[i], listlen(tmp[i], "-"), "-")> > <cfset tmp[i] = var1 & "_" & listlast(tmp[i], "-")> > > </cfloop> > > <cfdump var="#tmp#"> > > I'm sure there's a cleaner regex for it but like I said... I suck at those. > I was surprised to get the last one to work at all to be honest with you. > > As for updating all the records... can't you just select them, loop them, > and update them? This isn't something you are going to do redundantly is it? > Seems to be more of a one-time clean up script? > > So instead of the array, it would be your query results. > > -----Original Message----- > From: Ken [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 03, 2005 8:41 PM > To: CF-Talk > Subject: Re: String replace > > Also, in your code, you are presuming there will always be 2 dashes in > the string. The code won't work if there are 3 dashes, Like this: > Adi5RT-Flo12-Roy-3(Lg). Can this code be made flexible? > > On 8/3/05, Ewok <[EMAIL PROTECTED]> wrote: > > This seems to work as well ( to my surprise since I suck at regex's) > > > > > > <cfset tmp = arraynew(1)> > > > > <cfset tmp[1] = "Adi5RT-Flo12Roy-3(Lg)"> > > <cfset tmp[2] = "Adi5RT-FSU2Red-2(Md)"> > > <cfset tmp[3] = "Adi5RT-FSU2Red-3(Lg)"> > > <cfset tmp[4] = "Adi5RT-FSU2Red-4(XL)"> > > <cfset tmp[5] = "Adi5RT-FSU2Red-5(2X)"> > > <cfset tmp[6] = "Adi5RT-FSU3Wht-2(Md)"> > > <cfset tmp[7] = "Adi5RT-FSU3Wht-3(Lg)"> > > > > <cfloop from="1" to="#arraylen(tmp)#" index="i"> > > <cfset tmp[i] = rereplace(tmp[i], "(.*?-.*?)-(.*)", "\1_\2")> > > </cfloop> > > > > <cfdump var="#tmp#"> > > > > > > > > -----Original Message----- > > From: Ken [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, August 03, 2005 8:05 PM > > To: CF-Talk > > Subject: String replace > > > > Hi I have a db column as displayed below. I want to replace the last > > "-" with a underscore "_". Note: I don't want to replace all the > > dashes. Just the last one. It should look like this: > > Adi5RT-Flo12Roy_3(Lg). Any ideas? > > > > Adi5RT-Flo12Roy-3(Lg) > > Adi5RT-FSU2Red-2(Md) > > Adi5RT-FSU2Red-3(Lg) > > Adi5RT-FSU2Red-4(XL) > > Adi5RT-FSU2Red-5(2X) > > Adi5RT-FSU3Wht-2(Md) > > Adi5RT-FSU3Wht-3(Lg) > > > > Thanks, > > Kenny > > > > > > > > > > > > > > > >
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:213687 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

