// 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#"\"response-code\":\"(?<responsecode>[^\"]*)\".*\"description\":\"(?<description>[^\"]*)\""#).unwrap();
let string = "{\"sim-slot\":\"0\",\"terminal-vendor\":\"Vendor\",\"default-sms-app\":\"own\",\"screen-orientation\":\"portrait\",\"response-code\":\"200\",\"secondary-device-type\":\"\",\"international\":\"0\",\"subject-region\":\"Lat=0,Lon=0,Alt=0,Acc=0\",\"locale\":\"en_US\",\"timestamp\":\"2017-01-19T13:24:22.986+00:00\",\"user-agent\":\"IM-client/OMA1.0 model/brand-5.1 RCSAndrd/0.0.0 COMLib/0.00.00.rev00000\",\"evt-client-version\":\"0.0.0\",\"active-cs-call\":\"no\",\"sbc-ip\":\"99.99.9.999:9999\",\"transaction-id\":\"9aa99a9a-9aa9-99a9-a999-a9a9a999aa00\",\"init-service-tag\":\"audiocall\",\"description\":\"call-sip-invite-parent\",\"call-id\":\"ZZZZZZZZZZZ\",\"app-state\":\"foreground\",\"module\":\"cs\",\"terminal-sw-version\":\"0.0\",\"imsi\":\"99999999999\",\"remote-peer\":\"+99999999999\",\"cell-id\":\"99999\",\"platform\":\"phone-android\",\"client-version\":\"3.10.32.rev74692\",\"direction\":\"outgoing\",\"network-bearer\":\"CELLULAR_LTE\",\"terminal-model\":\"Model\",\"sim\":\"mcc(000),mnc(000)\",\"result\":\"success\",\"identity\":\"+999999999999\",\"device-id\":\"imei(9999999999),tac(99999)\"}";
// 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/