// 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"(.*:[\w]{2} )(.*)").unwrap();
let string = "drwxr-xr-x 0 0 2017-04-01 09:15 app
drwxr-xr-x 0 2000 2017-03-30 20:53 bin
-rw-r--r-- 0 0 10911 2017-04-11 18:53 build.prop
drwxr-xr-x 0 0 2017-04-01 09:14 data-app
drwxr-xr-x 0 0 2017-06-05 22:01 etc
drwxr-xr-x 0 0 2017-03-30 20:53 fonts
drwxr-xr-x 0 0 2017-04-17 20:39 framework
drwxr-xr-x 0 0 2017-03-30 20:53 lib
drwxr-xr-x 0 0 2017-03-30 20:53 lib64
drwxrwx--- 0 0 2017-03-30 20:52 lost+found
drwxr-xr-x 0 0 2017-03-31 05:58 media
drwxr-xr-x 0 0 2017-04-01 09:16 priv-app
drwxr-xr-x 0 0 2017-03-30 20:54 rfs
drwxr-xr-x 0 0 2017-03-30 20:54 spaces
drwxr-xr-x 0 0 2017-03-30 20:54 usr
drwxr-xr-x 0 2000 2017-03-30 20:54 vendor
drwxr-xr-x 0 2000 2017-03-30 20:54 xbin";
// 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/