// 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)[^[:print:]]\[[^a-zA-Z]*[a-zA-Z]").unwrap();
let string = "[BEGIN TYPESCRIPT]
[H[JLinux dcim-mao 4.19.0-20-cloud-amd64 #1 SMP Debian 4.19.235-1 (2022-03-17) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Jul 10 08:00:55 2023 from 172.17.0.2
[?2004hroot@dcim-mao:~# cd
[?2004l
[?2004hroot@dcim-mao:~# ls
[?2004l
[?2004hroot@dcim-mao:~# cd /
[?2004l
[?2004hroot@dcim-mao:/# ls
[?2004l
app etc media public srv usr
bin home mnt root supervisor.conf var
boot lib opt run sys
dev lib64 proc sbin tmp
[?2004hroot@dcim-mao:/#
[END TYPESCRIPT]";
// 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/