This is untested, but should be close.

REReplace(string, "[a-zA-Z0-9_-]+\.cfm\?code=([A-Z]{2})", "\1.html", "all")

find zero or more a-zA-Z0-9_-, then ".cfm?code=", then any two A-Z and
replace the whole thing with thos upper case letters plus ".html".  If
"someCFMFile.cfm" is static, you can replace that character class with
the literal.

cheers,
barneyb

On Tue, May 12, 2009 at 9:20 AM, Robert Nurse <rnu...@gmail.com> wrote:
>
> Hi All,
>
> I'm trying to find a way of using regular expressions to locate and replace 
> text.  My application reads in some text containing links from a DB: e.g. 
> ../folderName/someCFMFile.cfm?code=AB.  I want to change all occurrences of 
> this to ../folderName/AB.html.  Note that "code" can be any 
> 2-uppercase-character combination.  I've gotten to the point where I have 
> ../folderName/code using:
>
> <cfset aData = Replace(stringFromDB, "someCFMFile.cfm", "", "ALL")>
> <cfset aData = REReplace(aData, "../folderName/[A-Z]{2}", aData, "ALL")>
>
>
> My problem is how to get it to replace what it matches with that same match 
> (which would be ../folderName/code) with ../folderName/code.html?
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322428
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to