From e601bc8865e31e4716c23298fe61ffa8c228b010 Mon Sep 17 00:00:00 2001 From: lubber-de Date: Thu, 14 Dec 2023 23:36:48 +0100 Subject: [PATCH] feat(search): non greedy regexp match --- src/definitions/modules/dropdown.js | 2 +- src/definitions/modules/search.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 5f23d8407b..3da1bde62c 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -949,7 +949,7 @@ var querySplit = query.split(''), diacriticReg = settings.ignoreDiacritics ? '[\u0300-\u036F]?' : '', htmlReg = '(?![^<]*>)', - markedRegExp = new RegExp(htmlReg + '(' + querySplit.join(diacriticReg + ')(.*)' + htmlReg +'(') + diacriticReg + ')', regExpIgnore), + markedRegExp = new RegExp(htmlReg + '(' + querySplit.join(diacriticReg + ')(.*?)' + htmlReg +'(') + diacriticReg + ')', regExpIgnore), markedReplacer = function(){ var args = [].slice.call(arguments,1, querySplit.length * 2).map(function(x, i){ return i & 1 ? x : '' + x + ''}) diff --git a/src/definitions/modules/search.js b/src/definitions/modules/search.js index becd456606..8502c9e47e 100644 --- a/src/definitions/modules/search.js +++ b/src/definitions/modules/search.js @@ -1100,7 +1100,7 @@ querySplit = module.get.value().split(''), diacriticReg = settings.ignoreDiacritics ? '[\u0300-\u036F]?' : '', htmlReg = '(?![^<]*>)', - markedRegExp = new RegExp(htmlReg + '(' + querySplit.join(diacriticReg + ')(.*)' + htmlReg +'(') + diacriticReg + ')', regExpIgnore), + markedRegExp = new RegExp(htmlReg + '(' + querySplit.join(diacriticReg + ')(.*?)' + htmlReg +'(') + diacriticReg + ')', regExpIgnore), markedReplacer = function(){ var args = [].slice.call(arguments,1, querySplit.length * 2).map(function(x, i){ return i & 1 ? x : '' + x + ''})