fix: word boundaries, no regex lookbehind support for Safari (#1114)

This commit is contained in:
Elliot DeNolf
2022-09-12 10:28:29 -07:00
committed by GitHub
parent 8e47961da1
commit 391c9d8682

View File

@@ -2,7 +2,7 @@ export default (input: string): RegExp => {
const words = input.split(' ');
// Regex word boundaries that work for cyrillic characters - https://stackoverflow.com/a/47062016/1717697
const wordBoundaryBefore = '(?:(?<=[^\\p{L}\\p{N}])|^)';
const wordBoundaryBefore = '(?:(?:[^\\p{L}\\p{N}])|^)'; // Converted to a non-matching group instead of positive lookbehind for Safari
const wordBoundaryAfter = '(?=[^\\p{L}\\p{N}]|$)';
const regex = words.reduce((pattern, word, i) => {