// 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)^(?<date>\d{2}\.\d{2}\.\d{4})\s(?<time>\d{2}:\d{2}:\d{2}\.\d{3})\s{2}(?<msg>.+?(?=\s\d))\s(?<id>.{4})\s(?<name>.+?(?=$|\d{2}\.))(?<comment>.*$)").unwrap();
let string = "04.08.2024 06:41:14.775 Получено время 2447 Название устройства №2 04.08.2024 6:41:15 - синхронизация не требуется
04.08.2024 06:43:14.786 Получено время 22B3 Название устройства №3 04.08.2024 6:43:16 - время получения ответа превышает допуск
04.08.2024 11:47:01.967 Истекли попытки отправить запрос 234C Название устройства №4
05.08.2024 14:03:55.149 Получено время 2356 Название устройства №1 05.08.2024 14:03:57 - время получения ответа превышает допуск
05.08.2024 14:03:56.796 Получено время 2356 Название устройства №1 05.08.2024 14:03:58 - требуется синхронизация
05.08.2024 14:03:58.920 Установлена коррекция времени 2356 Название устройства №1";
// 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/