// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?m)^(.*?) \d{1,2}\/ ?(\d{1,2})\/ ?\d{4}(?: (?:ONE DAY|(?:\d{1,2}\/ ?(\d{1,2})\/ ?\d{4})))? (.*)$").unwrap();
let string = "Forest Moon 12/2/2018 12/3/2018 Assault Battles
Home One 12/5/2018 ONE DAY Fleet Mastery
The Artist of War 12/ 6/ 2018 12/ 12/ 2018 Legendary
Chimera 12/7/2018 12/ 13/ 2018 Legendary
Endor Escalation 12/8/2018 ONE DAY Heroic
The Artist of War 12/8/2018 12/9/2018 Mythic
Ground War 12/ 10/2018 12/ 11/2018 Assault Battles
Ewoks and Empire 12/13/2018 ONE DAY Omega Battles
Executrix 12/ 15/2018 ONE DAY Fleet Mastery
Rebel Round-Up 12/ 16/2018 12/ 17/ 2018 Assault Battles
Secrets and Shadows 12/ 19/ 2018 12/ 20/2018 Assault Battles
Endurance 12/ 21/2018 ONE DAY Fleet Mastery
Military Might 12/ 22/2018 12/ 23/2018 Assault Battles
Ghosts of Dathomir 12/22/2018 ONE DAY Special Event
Rebels and Geonosians 12/24/2018 ONE DAY Omega Battles
Ground War 12/24/2018 12/25/ 2018 Assault Battles
Grandmaster's Training 12/24/2018 12/25/2018 Mythic
Ewoks and Empire 12/25/2018 ONE DAY Omega Battles
Military Might 12/ 25/2018 12/ 26/2018 Assault Battles
Executrix 12/ 25/ 2018 ONE DAY Fleet Mastery
The Artist of War 12/ 25/ 2018 12/ 26/ 2018 Mythic
One Famous Wookie 12/25/2018 1/8/2019 Legendary
Jedi and Tusken 12/26/2018 ONE DAY Omega Battles
Forest Moon 12/26/2018 12/27/2018 Assault Battles
Home One 12/26/2018 ONE DAY Fleet Mastery
Sith and Droids 12/27/2018 ONE DAY Omega Battles
Secrets and Shadows 12/ 27/ 2018 12/ 28/2018 Assault Battles
Endurance 12/27/2018 ONE DAY Fleet Mastery
Emperor's Demise 12/ 27/ 2018 12/ 28/ 2018 Mythic
Nightsisters and Jawas 12/28/2018 ONE DAY Omega Battles
Geonosian Fleet Advanced Tactic 12/28/2018 ONE DAY Fleet Mastery
Rebel Round-Up 12/28/2018 12/29/2018 Assault Battles
Daring Droid 12/ 28/ 2018 12/ 29/ 2018 Mythic
Resistance and Clones 12/29/2018 ONE DAY Omega Battles
Places of Power 12/ 29/2018 12/ 30/2018 Assault Battles
Pieces and Plans 12/29/2018 12/ 30/2018 Mythic
First Order and Scoundrels 12/30/2018 ONE DAY Omega Battles
Defense of Dathomir 12/31/2018 1/1/2019 Heroic
|
ITB START DATE
Imperial Retaliation 12/3/2018 Territory Battle ‘
Rebel Assault 12/ 13/2018 Territory Battle l
Imperial Retaliation 12/ 20/ 2018 Territory Battle
TW PREVIEW PHASE
War 53-A 12/ 1/ 2018 Territory War
War 54-8 12/ 11/ 2018 Territory War |
War 55—A 12/ 29/ 2018 Territory War
War 56-3 1/ 2/ 2018 Territory War ‘";
let substitution = "$2-$3.......$4 - $1";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Rust, please visit: https://docs.rs/regex/latest/regex/