// 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)((g[íìỉĩị]|q[úùủũụứừửữự])[aăâeêoôơuưiy])[a-z]*|([bcdfhjklmnprstvxzđ]*[aăâeoôơuưiy][áàảãạắằẳẵặấầẩẫậéèẻẽẹóòỏõọốồổỗộúùủũụứừửữựýỳỷỹỵíìỉĩị])$|([a-zđ]*[áàảãạắằẳẵặấầẩẫậéèẻẽẹóòỏõọốồổỗộúùủũụứừửữựýỳỷỹỵíìỉĩị][aăâêeoôơuưiy][aăâeêoôơuưiybcdfghklmnpqrstvx]+)|([bcdfghjklmnpqrstvxzđ]*[aăâêeoôơuưiy][aăâêeoôơuưiy][áàảãạắằẳẵặấầẩẫậéèẻẽẹóòỏõọốồổỗộúùủũụứừửữựýỳỷỹỵíìỉĩị][bcdfghjklmnpqrstvxz]*)|([a-zăâôơưđ]*[áàảãạắằẳẵặấầẩẫậóòỏõọốồổỗộờớởỡợúùủũụứừửữựýỳỷỹỵíìỉĩị][a-z]*ê[a-zăâôơư]*)|([a-zăâôêưđ]*[áàảãạắằẳẵặấầẩẫậếềểễệóòỏõọốồổỗộúùủũụứừửữựýỳỷỹỵíìỉĩị][a-z]*ơ[a-zăâôơư]*)").unwrap();
let string = "hoạ
hoà
haọ
keó
meọ
coí
gían
gíong
gíêng
qúa
qúan
gìau
gìêng
chụyên
chuỵên
lúyên
luỵên
túê
tụê
hòang
hùynh
tòan
tươí
toaì
tóai
chuyện
nguyễn
hào
pháo
táo
tợn
huỳnh
hoàng
choáng
láng
ngáng";
// 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/