Escapes the RegExp special characters "^", "$", "", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in string.
RegExp
string
5.12.0
[[escape]], [[escapeRegExp]], [[unescape]]
escapeRegExp('[lodash](https://lodash.com/)')// => '\[lodash\]\(https://lodash\.com/\)' Copy
escapeRegExp('[lodash](https://lodash.com/)')// => '\[lodash\]\(https://lodash\.com/\)'
The string to escape.
string Returns the escaped string.
Escapes the
RegExp
special characters "^", "$", "", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" instring
.Since
5.12.0
See
[[escape]], [[escapeRegExp]], [[unescape]]
Example