Merge pull request #275 from Symbiomatrix/wildcard

This commit is contained in:
DominikDoom
2024-03-03 13:43:27 +01:00
parent 312cec5d71
commit d4041096c9
7 changed files with 35 additions and 13 deletions

View File

@@ -189,7 +189,11 @@ function toNgrams(inputArray, size) {
);
}
function escapeRegExp(string) {
function escapeRegExp(string, wildcardMatching = false) {
if (wildcardMatching) {
// Escape all characters except asterisks and ?, which should be treated separately as placeholders.
return string.replace(/[-[\]{}()+.,\\^$|#\s]/g, '\\$&').replace(/\*/g, '.*').replace(/\?/g, '.');
}
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
function escapeHTML(unsafeText) {