fix(katana): only regex if the word length is > 2

This commit is contained in:
tretrauit 2024-01-10 15:32:30 +07:00
parent f13d50e0f6
commit 8c1e39708f

View File

@ -178,11 +178,14 @@ fn regexify_text(text: &String) -> String {
ascii_text.push(' ');
}
}
ascii_text.split_whitespace().for_each(|word| {
for word in ascii_text.split_whitespace() {
if word.len() < 2 && regex.len() > 0 {
continue;
}
regex.push_str("(?=.*\\b");
regex.push_str(word.to_lowercase().as_str());
regex.push_str("\\b)");
});
}
regex.push_str(".+");
trace!("Regex: {}", regex);
regex