tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

string-replace-escaped.js (795B)


      1 // Copyright 2017 Aleksey Shvayka. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: Do not replace $<> preceded with $
      6 esid: sec-getsubstitution
      7 features: [regexp-named-groups]
      8 info: |
      9  Runtime Semantics: GetSubstitution( matched, str, position, captures, namedCaptures, replacement )
     10 
     11  12. These $ replacements are done left-to-right, and, once such a replacement is performed,
     12  the new replacement text is not subject to further replacements.
     13 
     14  Table: Replacement Text Symbol Substitutions
     15 
     16  Unicode Characters: $$
     17  Replacement text: $
     18 ---*/
     19 
     20 let source = "(?<fst>.)";
     21 for (let flags of ["", "u"]) {
     22  let re = new RegExp(source, flags);
     23  assert.sameValue("$<fst>bc", "abc".replace(re, "$$<fst>"));
     24 }
     25 
     26 reportCompare(0, 0);