Escapes unknown text so it can be used to create a RegExp. source
RegExp
const str = "some/path/"const escaped = escapeRegex(str) // some/path/const regex = new RegExp(`${escaped}.*?/`) Copy
const str = "some/path/"const escaped = escapeRegex(str) // some/path/const regex = new RegExp(`${escaped}.*?/`)
Escapes unknown text so it can be used to create a
RegExp
. source