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//

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

Created: 07/17/2018

Components: Functions

Versions: 2016,13.0

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: