UNPKG

409 BJavaScriptView Raw
1'use strict'
2
3/**
4 * @description Replace String based on RegExp
5 *
6 * @method escapeRegexpString
7 *
8 * @param {String} input Input
9 *
10 * @return {Function} input Replaced Input
11 */
12function escapeRegexpString (input) {
13 // match Operators
14 const match = /[|\\{}()[\]^$+*?.]/g
15
16 return input.replace(match, '\\$&')
17}
18
19/**
20 * @module escape
21 *
22 * @type {Function}
23 */
24module.exports = escapeRegexpString