// 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#"\"tag\"\:\"(?<image>([^\/]+\/){2})(?<service>[^\/]+)\/(?<id>[^\"]+)"#).unwrap();
let string = "{\"line\":\"[ERROR ] CWWKG0031E: The value jdbc/actionateDB specified for unique attribute jndiName is already in use.\",\"source\":\"stderr\",\"tag\":\"itec-artifactory.dis.com:6555/com.dis.pl000123.demo.actionate:0.0.1-25/Actionate_DEV_ACTIONATE.1.5tv4m4ckohx526muwvkcyo0v6/a078f70a8338\"}
{\"line\":\"[WARNING ] CWWKG0076W: The previous configuration for jndiReferenceEntry with id customDataSourceFactoryEntry is still in use.\",\"source\":\"stdout\",\"tag\":\"itec-artifactory.dis.com:6555/com.dis.pl000123.demo.actionate:0.0.1-25/Actionate_DEV_ACTIONATE.1.5tv4m4ckohx526muwvkcyo0v6/a078f70a8338\"}
{\"line\":\"\",\"source\":\"stdout\",\"tag\":\"itec-artifactory.dis.com:6555/com.dis.pl000123.demo.actionate:0.0.1-25/Actionate_DEV_ACTIONATE.1.5tv4m4ckohx526muwvkcyo0v6/a078f70a8338\"}
{\"line\":\"++ dirname /config/configDropins/defaults/keystore.xml\",\"source\":\"stderr\",\"tag\":\"itec-artifactory.dis.com:6555/com.dis.pl000123.demo.actionate:0.0.1-25/Actionate_DEV_ACTIONATE.1.5tv4m4ckohx526muwvkcyo0v6/a078f70a8338\"}";
// 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/