convert Ruby back reference to JS format in String#sub