// 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)\"Id\":"(\d+)","LocalTime":"(\d+)""#).unwrap();
let string = "2020-06-05 01:00:33.919 INFO [Thread-261246][HClient.java:256] - post successefully
2020-06-05 01:00:33.920 INFO [Thread-261246][HClient.java:257] - {\"ResponseStatusListObject\":{\"ResponseStatusObject\":[{\"RequestURL\":\"/VIID/Faces\",\"StatusCode\":\"0\",\"StatusMessage\":\"正常\",\"Id\":\"31010713011328005232\",\"LocalTime\":\"20200605005843\"}]}}
2020-06-05 01:00:33.920 INFO [Thread-261246][PutuoHandle.java:104] - list send end, listSize:6, sendTime:757ms
2020-06-05 01:00:34.160 INFO [Thread-261248][HClient.java:256] - post successefully
2020-06-05 01:00:34.160 INFO [Thread-261248][HClient.java:257] - {\"ResponseStatusListObject\":{\"ResponseStatusObject\":[{\"RequestURL\":\"/VIID/Faces\",\"StatusCode\":\"0\",\"StatusMessage\":\"正常\",\"Id\":\"31010712011328005082\",\"LocalTime\":\"20200605010212\"}]}}
2020-06-05 01:00:34.196 INFO [Thread-261247][HClient.java:256] - post successefully
2020-06-05 01:00:34.196 INFO [Thread-261247][HClient.java:257] - {\"ResponseStatusListObject\":{\"ResponseStatusObject\":[{\"RequestURL\":\"/VIID/Faces\",\"StatusCode\":\"0\",\"StatusMessage\":\"正常\",\"Id\":\"31010712011328005082\",\"LocalTime\":\"20200605010240\"}]}}
2020-06-05 01:00:34.196 INFO [Thread-261247][PutuoHandle.java:104] - list send end, listSize:5, sendTime:954ms
2020-06-05 01:00:34.323 INFO [Thread-261248][HClient.java:256] - post successefully
2020-06-05 01:00:34.323 INFO [Thread-261248][HClient.java:257] - {\"ResponseStatusListObject\":{\"ResponseStatusObject\":[{\"RequestURL\":\"/VIID/Faces\",\"StatusCode\":\"0\",\"StatusMessage\":\"正常\",\"Id\":\"31010713011328005232\",\"LocalTime\":\"20200605005843\"}]}}
2020-06-05 01:00:34.510 INFO [Thread-261248][HClient.java:256] - post successefully
2020-06-05 01:00:34.510 INFO [Thread-261248][HClient.java:257] - {\"ResponseStatusListObject\":{\"ResponseStatusObject\":[{\"RequestURL\":\"/VIID/Faces\",\"StatusCode\":\"0\",\"StatusMessage\":\"正常\",\"Id\":\"31010711011328005078\",\"LocalTime\":\"20200605010240\"}]}}
2020-06-05 01:00:34.510 INFO [Thread-261248][PutuoHandle.java:104] - list send end, listSize:5, sendTime:1464ms
2020-06-05 01:00:48.939 INFO [Timer-0][PutuoHandleThread.java:29] - area=>PT_AREA cameraType=>HK_TP groupCount=>3
2020-06-05 01:00:48.939 INFO [Timer-0][DbUtil.java:118] - getLastMaxId, cameraType:HK_TP, area:PT_AREA
2020-06-05 01:00:48.940 INFO [Timer-0][DbUtil.java:129] - sql=SELECT maxid FROM t_flag_info WHERE cameraType = ? AND area = ?, 1:HK_TP, 2:PT_AREA";
// 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/