// 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)^DTSTART:(.+)$").unwrap();
let string = "BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:1. Bundesliga
X-WR-TIMEZONE:Europe/Berlin
X-WR-CALDESC:iCal-Spielplan mit allen Spielen der 1. Bundesliga 2013-2014 -
gratis abonnieren!
BEGIN:VEVENT
DTSTART:20150226T200500Z
DTEND:20150226T220500Z
DTSTAMP:20150227T073355Z
UID:jmgapu2jbqhsesbpjlfc495c90@google.com
CREATED:20141216T183608Z
DESCRIPTION:Europa League\\, Zw.\\n\\nhttp://www.fussball-spielplan.de
LAST-MODIFIED:20150226T221219Z
LOCATION:
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY:Sporting Lissabon - VfL Wolfsburg (0:0)
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART:20150226T180000Z
DTEND:20150226T200000Z
DTSTAMP:20150227T073355Z
UID:uorcsvdsc24f37frgm36f3sfak@google.com
CREATED:20141216T164808Z
DESCRIPTION:Europa League\\, Zw.\\n\\nhttp://www.fussball-spielplan.de
LAST-MODIFIED:20150226T200016Z
LOCATION:Borussia-Park\\, Mönchengladbach
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY:Bor. Mönchengladbach - FC Sevilla (2:3)
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART:20150225T194500Z
";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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/