// 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"(?mxu)#проверка ФИО
#https://www.bbc.co.uk/academy/ru/articles/art20170623191659259
#https://www.regular-expressions.info/unicode.html
^
(?!^\s*[\p{Pd}’'])
(?![\s\S]*[\p{Pd}’']\s*$)
(?![\s\S]*?’’)
(?![\s\S]*?'')
#русские и английские буквы не могут быть одновременно
(?: (?![\s\S]*[aeiouyAEIOUY]{4}) #no 4 vowel letters sequentially
(?![\s\S]*[bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ]{5}) #no 5 consonant letters sequentially
(?:[a-zA-Z\p{Pd}’']|(?![\r\n])\s)+
| (?![\s\S]*?[аеиоуыэюяёАЕИОУЫЭЮЯЁ]{4}) #не может содержать 4 гласных буквы подряд (3 гласных буквы подряд есть в слове 'длинношеее')
(?![\s\S]*?[бвгджзклмнпрстфхцчшщйъьБВГДЖЗКЛМНПРСТФХЦЧШЩЙЪЬ]{6}) #не может содержать 6 согласных букв подряд (5 согласных букв подряд есть в фамилии 'Мкртчан')
(?:[а-яёА-ЯЁ\p{Pd}’']|(?![\r\n])\s)+
)
$").unwrap();
let string = "Ииии
Нннннн
Ttttt
Uuuu
АлисаTab
Алиса Tab
Иван'
-Alex
Жан-Клод Ван Дам
Алиса--Виктория
Алиса–Виктория
Алиса—Виктория
Иван Иванович Иванов
Динношееев
Мкртчан
д’Артаньян
Ali Baba
Jhon Smith";
// 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/