fix(katana): ah shit regex

This commit is contained in:
tretrauit 2024-01-12 18:48:47 +07:00
parent 0f97ec8810
commit d13e26c076
2 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,5 @@
use std::process::Command; use std::process::Command;
// Example custom build script. // Example custom build script.
fn main() { fn main() {
// Get the git commit hash (short) // Get the git commit hash (short)

View File

@ -222,8 +222,15 @@ fn regexify_text(text: &String) -> String {
} }
regex.push_str("(?=.*\\b"); regex.push_str("(?=.*\\b");
let processed_word = word.to_lowercase(); let processed_word = word.to_lowercase();
if partial_match && processed_word.len() > 2 { if partial_match && processed_word.len() > 3 {
regex.push_str(&processed_word[2..(word.len() - 2)]); if !processed_word[0..3].contains(|c: char| ['[', ']'].contains(&c))
&& !processed_word[word.len() - 3..word.len() - 1]
.contains(|c: char| ['[', ']'].contains(&c))
{
regex.push_str(&processed_word[2..word.len() - 2]);
} else {
regex.push_str(&processed_word.as_str());
}
} else { } else {
regex.push_str(&processed_word.as_str()); regex.push_str(&processed_word.as_str());
} }