tracker issue : CF-4203087

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

ReReplace - Can't escape special chars in backreference

| View in Tracker

Status/Resolution/Reason: To Fix//NeedMoreInfo

Reporter/Name(from Bugbase): John Whish / ()

Created: 07/17/2018

Components: Language, Functions

Versions: 2016,2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: ACF2018 /

Priority/Frequency: Normal / Few users will encounter

Locale/System: / Platforms All

Vote Count: 0

Problem Description:
{code:java}
<cfscript>
function escapeSpecialCharsA(required string term) {
	return reReplace(term, '(\[|\])', '\\\1', 'all');
}
function escapeSpecialCharsB(required string term) {
	return reReplace(term, '([\[\]])', '\\\1', 'all');
}

function test(actual,expected) {
    writeDump({
        expected: expected, 
        got: actual
    });
}
test(escapeSpecialCharsA("[]"), "\\[\\]");
test(escapeSpecialCharsB("[]"), "\\[\\]");
</cfscript>
{code}

Steps to Reproduce:
See above

Actual Result:
\[\]

Expected Result:
\\[\\]

Any Workarounds:

Works in Lucee!

Attachments:

Comments:

I see this is flagged as "NeedMoreInfo" - what more info do you need? Have you run the example?
Comment by John W.
32067 | January 28, 2020 02:19:06 PM GMT