Bug 21431 - String.replace does not support $& replacement metacharacter when search term is not a RegExp
Summary: String.replace does not support $& replacement metacharacter when search term...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Darin Adler
URL: javascript:alert("asdf".replace("as",...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2008-10-07 10:04 PDT by Mark Rowe (bdash)
Modified: 2009-01-02 01:06 PST (History)
1 user (show)

See Also:


Attachments
patch (6.15 KB, patch)
2008-12-30 23:26 PST, Darin Adler
oliver: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Rowe (bdash) 2008-10-07 10:04:12 PDT
"asdf".replace("as", "$&$&$&") gives "$&$&$&df" rather than the expected "asasasdf".

"asdf".replace(/as/, "$&$&$&") correctly gives "asasasdf".
Comment 1 Mark Rowe (bdash) 2008-10-07 10:08:20 PDT
<rdar://problem/6274993>
Comment 2 Darin Adler 2008-12-24 23:02:02 PST
stringProtoFuncReplace  needs to call substituteBackreferences on replacementString
Comment 3 Darin Adler 2008-12-30 23:26:37 PST
Created attachment 26331 [details]
patch
Comment 4 Darin Adler 2009-01-01 21:57:40 PST
http://trac.webkit.org/changeset/39542