# \_.escapeRegExp（转义正则特殊字符）

**语法：**

```javascript
_.escapeRegExp([string=''])
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L14272)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.escaperegexp)

**描述：**

转义`RegExp`字符串中特殊的字符 "^", "$", "", ".", "\*", "+", "?", "(", ")", "\[", "]", "{", "}", 和 "|" in .

**开始版本：**&#x33;.0.0

**参数：**

* `[string=''] (string)`: 要转义的字符串。

**返回值：**

* `(string)`: 返回转义后的字符串。

**例子：**

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