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 > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:213681 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

