discourse/app/assets/javascripts/discourse-common/addon/utils/escape-regexp.js
David Taylor c054a47d9a
DEV: Add escapeRegExp util (#17051)
This was re-implemented in a number of places - it makes more sense as a utility function.
2022-06-10 10:37:54 +10:00

4 lines
142 B
JavaScript

export default function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
}