// 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)\((\w{0,3})\)\s([A-Z,a-z,\s]+)\((.*)\)?\s+([\d,.].*)").unwrap();
let string = "Source: http://evds.tcmb.gov.tr/fame/webfactory/evdpw/rpt/1652.html
05-02-2016
(AUD) Avustralya Dolari (Doviz Alis) 2.08800
(AUD) Avustralya Dolari (Doviz Satis 2.10170
(BEF) Belcika Frangi (Doviz Alis) ..
(BEF) Belcika Frangi (Doviz Satis) ..
(BGN) Bulgar Levasi (Doviz Alis) 1.64750
(BGN) Bulgar Levasi (Doviz Satis) 1.66900
(CHF) Isvicre Frangi (Doviz Alis) 2.89220
(CHF) Isvicre Frangi (Doviz Satis) 2.91070
(EUR) Euro (Doviz Alis) 3.24060
(EUR) Euro (Doviz Satis) 3.24640
(RUB) Rus Rublesi (Doviz Alis) 0.03767
(RUB) Rus Rublesi (Doviz Satis) 0.03817
(USD) ABD Dolari (Doviz Alis) 2.90440
(USD) ABD Dolari (Doviz Satis) 2.90960";
// 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/