tickle/modules/utils/escapeRegExp.mjs
2023-06-07 22:07:47 +02:00

11 lines
233 B
JavaScript

//@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