escapeRegExp

String
since 3.0.0

Arguments

  • string The string to escape.

Returns

string the escaped string.

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

Example of Lodash _.escapeRegExp

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