diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -5,9 +5,13 @@ pub fn search<'a>(pattern: &str, contents: &'a str) -> Vec<&'a str> { .collect() } -pub fn contains_pattern(src: &str, pat: &str, ignore_case: bool) -> bool { +pub fn contains_pattern(src: &str, pat: &str, ignore_case: bool, word_regexp: bool) -> bool { let src = if ignore_case { src.to_lowercase() } else { src.to_owned() }; let pat = if ignore_case { pat.to_lowercase() } else { pat.to_owned() }; - src.contains(&pat) + if word_regexp { + src.split_whitespace().any(|p| p == pat) + } else { + src.contains(&pat) + } } |