Merge branch 'main' into feature-sort-by-frequent-use

This commit is contained in:
DominikDoom
2024-03-03 13:52:32 +01:00
9 changed files with 56 additions and 23 deletions

View File

@@ -309,7 +309,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) {