diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2023-04-04 17:17:09 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2023-04-04 17:17:09 +0200 |
commit | f1b973a4eb00c6aed1dc17a39c87d1c47fcf182a (patch) | |
tree | 7560936c610daec4919c967745875f3554632b94 | |
parent | 393eba224683f5ac475f9af1ede63478eb8279df (diff) |
More patterns
-rw-r--r-- | src/qif.rs | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -109,14 +109,15 @@ fn remove_date(text: &str) -> String { fn remove_card_number(text: &str) -> String { lazy_static! { - static ref CARD_NUM_REGEX: Regex = Regex::new(r"\d{6}\*+\d{4}").unwrap(); + static ref CARD_NUM_REGEX: Regex = Regex::new(r"(\d{6}\*+\d{4}|\d{16})").unwrap(); } CARD_NUM_REGEX.replace_all(text, "").trim().to_string() } fn remove_payment_provider(text: &str) -> String { lazy_static! { - static ref PURCH_REGEX: Regex = Regex::new(r"(?i)^(purch( payfast\*)?|pp \*)").unwrap(); + static ref PURCH_REGEX: Regex = + Regex::new(r"(?i)^(purch( payfast\*)?|pp \*|c\*|yoco \*|ikh*)").unwrap(); } PURCH_REGEX.replace_all(text, "").trim().to_string() } @@ -151,6 +152,7 @@ fn replace_common(text: &str) -> String { (r"(?i)(COUNTRY VIEW|STAR STOP|Shell|Sasol|Engen)", "Petrol"), (r"(?i)kung ?-?fu", "Kungfu Kitchen"), (r"(?i)^atm cash", "Cash"), + (r"(?i)DRS CL & ME LA", "Medipark 24") ) .into_iter() .map(|(from, to)| (Regex::new(from).unwrap(), to)) |