(match, str)
| 786 | } |
| 787 | replace(searchValue, replacement) { |
| 788 | function getReplacement(match, str) { |
| 789 | if (typeof replacement === 'string') { |
| 790 | return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => { |
| 791 | if (i === '$') return '$'; |
| 792 | if (i === '&') return match[0]; |
| 793 | const num = +i; |
| 794 | if (num < match.length) return match[+i]; |
| 795 | return `$${i}`; |
| 796 | }); |
| 797 | } else { |
| 798 | return replacement(...match, match.index, str, match.groups); |
| 799 | } |
| 800 | } |
| 801 | function matchAll(re, str) { |
| 802 | let match; |
| 803 | const matches = []; |