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:213678
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to