// 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)locks:(?<locks>\{.*?\}+[\s*\}]+)").unwrap();
let string = "[conn5695298] query entitydb_20014.chats query: { $query: { $or: [ { receiver_id: \"5b91eb3dfe860a5325533467\" }, { sender_id: \"5b91eb3dfe860a5325533467\" } ], send_time: { $gt: 0 } }, $orderby: { send_time: -1 } } planSummary: COLLSCAN, COLLSCAN ntoreturn:120 ntoskip:0 nscanned:0 nscannedObjects:2216688 scanAndOrder:1 keyUpdates:0 writeConflicts:0 numYields:18133 nreturned:0 reslen:20 locks:{ Global: { acquireCount: { r: 36268 }, acquireWaitCount: { r: 49 }, timeAcquiringMicros: { r: 8560 } }, MMAPV1Journal: { acquireCount: { r: 18134 }, acquireWaitCount: { r: 2 }, timeAcquiringMicros: { r: 554 } }, Database: { acquireCount: { r: 18134 } }, Collection: { acquireCount: { R: 18134 } } } 4547ms
planSummary: IXSCAN { host: 1, gid: 1, service_code: 1, name: 1, instance: 1 } cursorid:44314245057 keysExamined:20225 docsExamined:20050 cursorExhausted:1 numYields:158 nreturned:20050 reslen:1596954 locks:{ Global: { acquireCount: { r: 318 } }, Database: { acquireCount: { r: 159 } }, Collection: { acquireCount: { r: 159 } } } protocol:op_command 136ms
planSummary: IXSCAN { host: 1, gid: 1, service_code: 1, name: 1, instance: 1 } cursorid:44314245057 keysExamined:20225 docsExamined:20050 cursorExhausted:1 numYields:158 nreturned:20050 reslen:1596954 locks:{ Global: 5 }, Database: { acquireCount: { r: 159 } }} }} }}}} }}}}}}, Collection: { acquireCount: { r: 159 } } } protocol:op_command 136ms";
// 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/