aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 0c1a240..060dd84 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,7 +16,7 @@
use ical;
use chrono::{DateTime, TimeZone, Utc};
-use regex::Regex;
+use regex::RegexBuilder;
use std::fs::File;
use std::io::BufReader;
@@ -71,7 +71,10 @@ fn match_event(event: &ical::parser::ical::component::IcalEvent, pattern: &str)
let parts: Vec<&str> = pattern.split(':').collect();
let (key, pat) = (parts[0].to_uppercase(), parts[1]);
- let re = Regex::new(&pat).unwrap();
+ let re = RegexBuilder::new(&pat)
+ .case_insensitive(true)
+ .build()
+ .unwrap();
event.properties.iter()
.filter(|ref p| p.name == key && re.is_match(&p.value.clone().unwrap()))
@@ -112,6 +115,12 @@ fn match_events_by_regex() {
assert_eq!(1, events.len());
}
+#[test]
+fn match_events_regardless_of_case() {
+ let events:Vec<_> = test_match_event_helper("summary:^aLl.+1$");
+ assert_eq!(1, events.len());
+}
+
fn main() {
let mut args = std::env::args().skip(1);
let filename = args.next().unwrap();