4.17.11
3.10.1
2.4.2
1.3.1

_.escapeRegExp([string=''])

Escapes the RegExp special characters "^", "$", "", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in string.

Since

3.0.0

Arguments

argument
[string='']
type
string
description
The string to escape.

Returns

(array)

Example

_.escapeRegExp(
  "[lodash](https://lodash.com/)"
);
// => '\[lodash\]\(https://lodash\.com/\)'
_.escapeRegExp("[lodash](https://lodash.com/)");
// => '\[lodash\]\(https://lodash\.com/\)'