Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
escapeRegExp('[lodash](https://lodash.com/)')
// => '\[lodash\]\(https://lodash\.com/\)'
Name | Type | Attribute | Description |
---|---|---|---|
string | The string to escape. |
{ "comment": "/**\r\n * Escapes the `RegExp` special characters \"^\", \"$\", \"\\\", \".\", \"*\", \"+\",\r\n * \"?\", \"(\", \")\", \"[\", \"]\", \"{\", \"}\", and \"|\" in `string`.\r\n *\r\n * @since 3.0.0\r\n * @category String\r\n * @param {string} [string=''] The string to escape.\r\n * @returns {string} Returns the escaped string.\r\n * @see escape, escapeRegExp, unescape\r\n * @example\r\n *\r\n * escapeRegExp('[lodash](https://lodash.com/)')\r\n * // => '\\[lodash\\]\\(https://lodash\\.com/\\)'\r\n */", "meta": { "range": [ 663, 806 ], "filename": "escapeRegExp.js", "lineno": 22, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100002273", "name": "escapeRegExp", "type": "FunctionDeclaration", "paramnames": [ "string" ] } }, "description": "Escapes the `RegExp` special characters \"^\", \"$\", \"\\\", \".\", \"*\", \"+\",\r\"?\", \"(\", \")\", \"[\", \"]\", \"{\", \"}\", and \"|\" in `string`.", "since": "3.0.0", "tags": [ { "originalTitle": "category", "title": "category", "text": "String", "value": "String" } ], "params": [ { "type": { "names": [ "string" ] }, "optional": true, "defaultvalue": "''", "description": "The string to escape.", "name": "string" } ], "returns": [ { "type": { "names": [ "string" ] }, "description": "Returns the escaped string." } ], "see": [ "escape, escapeRegExp, unescape" ], "examples": [ "escapeRegExp('[lodash](https://lodash.com/)')\r// => '\\[lodash\\]\\(https://lodash\\.com/\\)'" ], "name": "escapeRegExp", "longname": "escapeRegExp", "kind": "function", "scope": "global", "___id": "T000002R000252", "___s": true, "filepath": "escapeRegExp.js" }