// 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#"(?ms)<[Rr]epresentation[^>]*?[Bb]andwidth="0?[2-9]\d{6}"[\s\S]*?[Rr]epresentation>"#).unwrap();
let string = "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\" minBufferTime=\"PT1.500000S\" type=\"static\" mediaPresentationDuration=\"PT0H9M54.00S\" profiles=\"urn:mpeg:dash:profile:isoff-live:2011\">
<ProgramInformation moreInformationURL=\"http://gpac.sourceforge.net\">
<Title>/home/elkhatib/Documents/dash264/TestCases/2b/qualcomm/2_BBB_5Sec_MainProf/MultiRes.mpd generated by GPAC</Title>
</ProgramInformation>
<Period id=\"\" duration=\"PT0H9M54.00S\">
<AdaptationSet segmentAlignment=\"true\" maxWidth=\"1280\" maxHeight=\"720\" maxFrameRate=\"24\" par=\"16:9\">
<Representation id=\"1\" mimeType=\"video/mp4\" codecs=\"avc1.4d401f\" width=\"512\" height=\"288\" frameRate=\"24\" sar=\"1:1\" startWithSAP=\"1\" bandwidth=\"2000000\">
<SegmentTemplate timescale=\"12288\" duration=\"61440\" media=\"BBB_512_640K_video_$Number$.mp4\" startNumber=\"1\" initialization=\"BBB_512_640K_video_init.mp4\" />
</Representation>
<Representation id=\"1\"
mimeType=\"video/mp4\"
codecs=\"avc1.4d401f\"
width=\"512\"
height=\"288\"
frameRate=\"24\"
sar=\"1:1\"
startWithSAP=\"1\"
bandwidth=\"1000000\">
<SegmentTemplate timescale=\"12288\" duration=\"61440\" media=\"BBB_512_640K_video_$Number$.mp4\" startNumber=\"1\" initialization=\"BBB_512_640K_video_init.mp4\" />
</Representation>
<Representation id=\"1\" mimeType=\"video/mp4\" codecs=\"avc1.4d401f\" width=\"512\" height=\"288\" frameRate=\"24\" sar=\"1:1\" startWithSAP=\"1\" bandwidth=\"2000000\">
<SegmentTemplate timescale=\"12288\" duration=\"61440\" media=\"BBB_512_640K_video_$Number$.mp4\" startNumber=\"1\" initialization=\"BBB_512_640K_video_init.mp4\" />
</Representation>
<Representation id=\"2\" mimeType=\"video/mp4\" codecs=\"avc1.4d401f\" width=\"768\" height=\"432\" frameRate=\"24\" sar=\"1:1\" startWithSAP=\"1\" bandwidth=\"4000000\">
<SegmentTemplate timescale=\"12288\" duration=\"61440\" media=\"BBB_768_1440K_video_$Number$.mp4\" startNumber=\"1\" initialization=\"BBB_768_1440K_video_init.mp4\" />
</Representation>
</AdaptationSet>
</Period>
</MPD>
";
// 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/