webpack/test/helpers/regexEscape.js

6 lines
158 B
JavaScript

"use strict";
module.exports = function regexEscape(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
};