// 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#"(?mi){\s*["']\s*streamUrl\s*["']\s*:\s*["']\s*(http[^"']+)"#).unwrap();
let string = "\"language\":[\"Français\"],\"logo100x100\":\"http://static.radio.fr/images/broadcasts/15/43/8275/1/c100.png\",
\"streamUrls\":[{\"streamUrl\":\"http://mp3lg4.tdf-cdn.com/9243/lag_164753.mp3\",\"loadbalanced\":false,
\"metaDataAvailable\":false,\"playingMode\":\"STEREO\",\"type\":\"STREAM\",\"sampleRate\":44100,\"streamContentFormat\":\"MP3\",
\"bitRate\":128,\"idBroadcast\":8275,\"sortOrder\":0,\"streamFormat\":\"ICECAST\",\"id\":47609,\"streamStatus\":\"VALID\",
\"contentType\":\"audio/mpeg\"},{\"streamUrl\":\"http://mp3lg3.scdn.arkena.com/10490/virginradio.mp3\",\"loadbalanced\":false,
\"metaDataAvailable\":false,\"playingMode\":\"STEREO\",\"type\":\"STREAM\",\"sampleRate\":44100,\"streamContentFormat\":\"MP3\",
\"bitRate\":64,\"idBroadcast\":8275,\"sortOrder\":1,\"streamFormat\":\"ICECAST\",\"id\":57003,\"streamStatus\":\"VALID\",
\"contentType\":\"audio/mpeg\"}],\"playable\":\"PLAYABLE\",\"genres\":[\"Pop\",\"Rock\"],
\"logo175x175\":\"http://static.radio.fr/images/broadcasts/15/43/8275/1/c175.png\",\"
";
// 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/