// 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)(?<=m=video)(?s)(.*)(a=sendrecv)").unwrap();
let string = "v=0
o=- 582127838 582127838 IN IP4 172.17.217.8
s=Commend
c=IN IP4 172.17.217.8
t=0 0
m=audio 16882 RTP/AVP 8 107 9 0
a=rtpmap:8 PCMA/8000
a=rtpmap:107 opus/48000/2
a=fmtp:107 useinbandfec=1
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=ptime:20
a=maxptime:20
a=sendrecv
m=video 15132 RTP/AVP 99
a=rtpmap:99 H264/90000
a=sendrecv
";
let substitution = "$1a=sendonly";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
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/