diff options
author | Norbert Preining <norbert@preining.info> | 2023-02-26 03:02:12 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-02-26 03:02:12 +0000 |
commit | e7ae872926eddb0de09ecfe1c578e0680033955a (patch) | |
tree | 01717465b5b26d3b2ccaea9889c720a840e0a16c /support/texlab/src/util/regex_filter.rs | |
parent | 81a9d839224eef4c2bd9bf68410b4049c61cdb14 (diff) |
CTAN sync 202302260302
Diffstat (limited to 'support/texlab/src/util/regex_filter.rs')
-rw-r--r-- | support/texlab/src/util/regex_filter.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/support/texlab/src/util/regex_filter.rs b/support/texlab/src/util/regex_filter.rs new file mode 100644 index 0000000000..f107ea16fe --- /dev/null +++ b/support/texlab/src/util/regex_filter.rs @@ -0,0 +1,24 @@ +use crate::RegexPattern; + +pub fn filter( + text: &str, + allowed_patterns: &[RegexPattern], + ignored_patterns: &[RegexPattern], +) -> bool { + if !allowed_patterns.is_empty() + && !allowed_patterns + .iter() + .any(|pattern| pattern.0.is_match(text)) + { + return false; + } + + if ignored_patterns + .iter() + .any(|pattern| pattern.0.is_match(text)) + { + return false; + } + + true +} |