// 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"(\b(?:\w+)?\d+(?:\w+)?(?:[\-\/])?(?:\w+)?(?:\d+)?\b)").unwrap();
let string = "Park Avenue number 100
Baker Street number 100
Baker Street 100
The bakery shop is located on 109-111 Wharfside Street
My mother's house is on 40-42 Parkway
My schoolmate lives in 25b-26 Sun Street
The apartment is located on R2-R3 City Quay
I live in 43a Garden Walk
I live in 6/7 Marine Road
I live in 10-12 Acacia Ave
I live in 4513 3RD STREET CIRCLE WEST
I live in 1/2 Fifth Avenue
number C3-H4 sawojajar Malang";
// 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/