package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?<=m=video)(?s)(.*)(a=sendrecv)`)
var str = `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
`
var substitution = "$1a=sendonly"
fmt.Println(re.ReplaceAllString(str, substitution))
}
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 Golang, please visit: https://golang.org/pkg/regexp/