diff --git a/lib/util/regex.ts b/lib/util/regex.ts
index 7cc415c653ae2fa54b3acffe30e5b2690f740232..eac1ad871b1199a7baa03cce053b554a77ff5397 100644
--- a/lib/util/regex.ts
+++ b/lib/util/regex.ts
@@ -25,3 +25,7 @@ export function regEx(pattern: string, flags?: string): RegExp {
     throw error;
   }
 }
+
+export function escapeRegExp(input: string): string {
+  return input.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
+}
diff --git a/lib/workers/branch/auto-replace.ts b/lib/workers/branch/auto-replace.ts
index 2023b5556d93e78bfb6dd553c171207884529344..a0f4b18d343a069cc3475670f53797559a63bc2c 100644
--- a/lib/workers/branch/auto-replace.ts
+++ b/lib/workers/branch/auto-replace.ts
@@ -2,7 +2,7 @@ import { logger } from '../../logger';
 import { get } from '../../manager';
 import { WORKER_FILE_UPDATE_FAILED } from '../../constants/error-messages';
 import { matchAt, replaceAt } from '../../util/string';
-import { regEx } from '../../util/regex';
+import { regEx, escapeRegExp } from '../../util/regex';
 
 export async function confirmIfDepUpdated(
   upgrade,
@@ -60,10 +60,6 @@ export async function checkBranchDepsMatchBaseDeps(
   }
 }
 
-function escapeRegExp(input: string): string {
-  return input.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
-}
-
 export async function doAutoReplace(
   upgrade,
   existingContent: string,