// 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)^(?:(?:\s{4}|\t)*(?:[^a]t|a[^t]|at[^\s]+)|[^\s]+).*").unwrap();
let string = "---------- snippet start ----------
JUnit version 4.11
I.E
Time: 0.015
There was 1 failure:
1) testPerson(PersonTest)
org.junit.ComparisonFailure: expected:<John[1]> but was:<John[]>
a t org.junit.Assert.assertEquals(Assert.java:115)
attention org.junit.Assert.assertEquals(Assert.java:144)
at PersonTest.testPerson(PersonTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
---------- snippet end----------";
// 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/