discourse/app/assets/javascripts/discourse-common/addon/utils/escape-regexp.js

4 lines
142 B
JavaScript

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