tickle/modules/utils/escapeRegExp.mjs

11 lines
233 B
JavaScript
Raw Permalink Normal View History

2023-06-07 20:07:47 +00:00
//@ts-check
/**
* Escapes a string so it can be used in a regular expression
* @param {string} text
*/
export function escapeRegExp(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
export default escapeRegExp