// 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)json:(?!.*json:.*totalCount.*).*?totalCount.*?(?=\[2)").unwrap();
let string = "[2018-12-10 06:30:44]JSON回调处理--->>> 同步运动数据 [2018-12-10 06:30:44]同步运动健康数据json:{ \"day\" : 10, \"items\" : [ { \"activeTime\" : 5, \"calory\" : 0, \"distance\" : 0, \"stepCount\" : 0 },
{ \"activeTime\" : 0, \"calory\" : 0, \"distance\" : 0, \"stepCount\" : 0 }, { \"activeTime\" : 0, \"calory\" : 0, \"distance\" : 0, \"stepCount\" : 0 } ], \"month\" : 12, \"startTime\" : 0, \"timeSpace\" : 15, \"totalActiveTime\" : 81, \"totalCalory\" : 0, \"totalDistance\" : 0, \"totalCount\" : 0, \"year\" : 2018 }
[2018-12-10 06:30:44]同步运动健康数据items.sise()=96
[2018-12-10 06:30:38]..再同步健康数据...
[2018-12-10 06:30:44]JSON回调处理--->>> 同步运动数据 [2018-12-10 06:30:44]同步运动健康数据json:{ \"day\" : 10, \"items\" : [ { \"activeTime\" : 5, \"calory\" : 0, \"distance\" : 0, \"stepCount\" : 0 },
{ \"activeTime\" : 0, \"calory\" : 0, \"distance\" : 0, \"stepCount\" : 0 }, { \"activeTime\" : 0, \"calory\" : 0, \"distance\" : 0, \"stepCount\" : 0 } ], \"month\" : 12, \"startTime\" : 0,
\"timeSpace\" : 15, \"totalActiveTime\" : 81, \"totalCalory\" : 0, \"totalDistance\" : 0, \"StepCount\" : 0, \"year\" : 2018 }
[2018-12-10 06:30:44]同步运动健康数据items.sise()=96
[2018-12-10 06:30:38]..再同步健康数据... ";
// 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/