fix: implement the same word boundary search as the like query (#1038)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
This commit is contained in:
7
src/utilities/wordBoundariesRegex.ts
Normal file
7
src/utilities/wordBoundariesRegex.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export default (input: string): RegExp => {
|
||||
const words = input.split(' ');
|
||||
const regex = words.reduce((pattern, word, i) => {
|
||||
return `${pattern}(?=.*\\b${word}.*\\b)${i + 1 === words.length ? '.+' : ''}`;
|
||||
}, '');
|
||||
return new RegExp(regex, 'i');
|
||||
};
|
||||
Reference in New Issue
Block a user