function escape
escape(str: string): stringEscapes arbitrary text for interpolation into a regexp, such that it will match exactly that text and nothing else.
Examples
Example 1
Example 1
import { escape } from "@std/regexp"; import { assertEquals, assertMatch, assertNotMatch } from "@std/assert"; const re = new RegExp(`^${escape(".")}$`, "u"); assertEquals("^\\.$", re.source); assertMatch(".", re); assertNotMatch("a", re);
Parameters
str: string