diff --git a/src/search.ts b/src/search.ts index 755663a..0daf463 100644 --- a/src/search.ts +++ b/src/search.ts @@ -293,11 +293,11 @@ class RegExpQuery extends QueryType { } getReplacement(result: RegExpResult) { - return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => + return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$" : i == "&" ? result.match[0] : i != "0" && +i < result.match.length ? result.match[i] - : m)) + : m) } matchAll(state: EditorState, limit: number) {