Created
January 30, 2018 18:14
-
-
Save 0xbe7a/04cac7957ab5e051666c09138f477159 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate regex; | |
use regex::Regex; | |
fn main() { | |
let r = match Regex::new(®ex::escape(r"\/[a-z]{3}\/[0-9]{4}")) { | |
Ok(r) => r, | |
Err(e) => { | |
println!("Could not compile regex: {}", e); | |
return; | |
} | |
}; | |
let string = "/dev/abc | |
/sys/3453 | |
/esp/3scs"; | |
// result will be an iterator over tuples containing the start and end indices for each match in the string | |
let result = r.find_iter(string); | |
println!("{:?}", string); | |
for m in result { | |
println!("{:?}", m); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment