bitapRegexSearch function
Execute a bitap regex search
Implementation
MatchScore bitapRegexSearch(
String text, String pattern, Pattern tokenSeparator) {
final regex = RegExp(pattern
.replaceAll(SPECIAL_CHARS_REGEX, r'\$&')
.replaceAll(tokenSeparator, '|'));
final matches = regex.allMatches(text);
final isMatch = matches.isNotEmpty;
return MatchScore(
score: isMatch ? 0.5 : 1,
isMatch: isMatch,
matchedIndices: matches.map((m) => MatchIndex(m.start, m.end)).toList(),
);
}