UNPKG
escape-regexp
Version:
latest (0.0.1)
0.0.1
Escape regular expression special characters
escape-regexp
/
index.js
12 lines
(10 loc)
•
219 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
/** * Escape regexp special characters in `str`. * *
@param
{
String
}
str
*
@return
{
String
} *
@api
public
*/
module
.
exports
=
function
(
str
){
return
String
(str).
replace
(
/([.*+?=^!:${}()|[\]\/\\])/g
,
'\\$1'
); };