// 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)^\s*(?<text>.*?)\s*((?<format>\([^)]*\))*\s*)*$").unwrap();
let string = "Chào mừng tất cả các anh chị đến với chủ đề dinh dưỡng và các bệnh về mắt.
Chủ đề trước chúng ta đã tìm hiểu về mắt, và chúng ta đã biết rất nhiều bệnh về mắt.
(text: Chủ đề dinh dưỡng và các bệnh về mắt; font-size:87;
typetext: giới thiệu;img: mat.jpg; effect: fadein; size: 6; subtext: đôi mắt khỏe;)
Sau đây chúng ta sẽ tìm hiểu một số bệnh cơ bản về mắt mà hiện nay xã hội đang tồn tại.";
// 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/