Escapes regex string into proper regex.

Type signature

(string: string) => string

Examples

escape("te.t").test("text");
// ⇒ false
Try in REPL

Questions

  • How to properly escape a regex string?

TypeScript sourceJavaScript source