Skip to content

Commit 112bd38

Browse files
author
Mercedes Rey
committed
Add the ability to search with a global regex
1 parent 5c69f49 commit 112bd38

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function getValuesForKey (key, item) {
3939
return results.filter(r => typeof r === 'string' || typeof r === 'number')
4040
}
4141

42-
export function searchStrings (strings, term, {caseSensitive, fuzzy, sortResults, exactMatch} = {}) {
42+
export function searchStrings (strings, term, {caseSensitive, fuzzy, sortResults, exactMatch, regexMatch} = {}) {
4343
strings = strings.map(e => e.toString())
4444

4545
try {
@@ -60,7 +60,9 @@ export function searchStrings (strings, term, {caseSensitive, fuzzy, sortResults
6060
}
6161
if (exactMatch) {
6262
term = new RegExp('^' + term + '$', 'i')
63-
}
63+
} else if (regexMatch) {
64+
term = new RegExp(term, 'i')
65+
}
6466
if (value && value.search(term) !== -1) {
6567
return true
6668
}

0 commit comments

Comments
 (0)