tracker issue : CF-3597432

select a category, or use search below
(searches all categories and all time range)
Title:

replaceWithCallback()

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 07/18/2013

Components: Language

Versions: 10.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: Final /

Priority/Frequency: Normal / All users will encounter

Locale/System: English / Platforms All

Vote Count: 3

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on August 26, 2019 using build 2016.0.01.298513
See http://cfmlblog.adamcameron.me/2013/07/replacewithcallback-udf-for-cflib-and.html for discussion.

Basically:
I was looking up the docs for Javascript's String replace() function the other day [and] I also noticed it can take a callback instead of a string for its replacement argument. How cool is that?

I figured this could be handy for CFML's reReplace() function too [... etc]

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3597432

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

I've found Adam's UDF invaluable for my task. I cannot recommend it highly enough for native inclusion into ColdFusion!
Vote by External U.
14907 | September 26, 2013 05:45:30 AM GMT
reReplace with callback support would be awesome. JavaScript has it. Ben coded one here with Java's regex: http://www.bennadel.com/blog/2331-ColdFusion-10-Beta-Closures-And-Function-Expressions.htm
Vote by External U.
14908 | January 09, 2014 02:57:48 PM GMT
What's actually been implemented here? I can find no docs for it.
Comment by External U.
14901 | February 18, 2016 07:36:23 AM GMT
Callback support added check - https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-m-r/replace.html
Comment by Vamseekrishna N.
14902 | February 18, 2016 08:47:16 AM GMT
And here is my reaction to *that*: http://blog.adamcameron.me/2016/02/coldfusion-2016-half-arsed-ness-from.html
Comment by External U.
14903 | February 18, 2016 09:01:15 AM GMT
Hi Vamsee, Thanks! Just a couple remaining issues: 1) It wasn't added to replaceNoCase(), reReplace() or reReplaceNoCase() (please see Adam's blog entry - URL in previous comment) 2) Callback should also receive "count of the current replacement operation" (please see discussion here: http://prerelease.adobe.com/r/?a817096ed9e14bceb4043e3cd7169bc2) Thanks!, -Aaron
Comment by External U.
14904 | February 20, 2016 11:08:05 PM GMT
+1
Vote by External U.
14909 | February 20, 2016 11:08:57 PM GMT
@Vamsee any chance you can not just start ignoring the ticket when the conversation isn't going in a way that's convenient for you?
Comment by External U.
14905 | November 22, 2016 04:28:59 PM GMT
Please see this new ticket which was created for the remaining functions. I also suggested a spec there for handing the callback in the regex-based functions. https://bugbase.adobe.com/index.cfm?event=bug&id=CF-4120177
Comment by External U.
14906 | November 22, 2016 10:21:52 PM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513), well except for Replace()'s 3 sibling functions of course. :/ Thanks!, -Aaron
Comment by Aaron N.
31217 | August 26, 2019 05:26:36 AM GMT