package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`src: \"[^\>]*\"\}`)
var str = `<![CDATA[
var playerInstance = new artiplayer('artimedia-player-0404-1',{
source: {type: "video/mp4", src: "https://www.lolka.co.il/wp-content/uploads/2018/12/Screen-Shot-2018.jpg"},
poster: "https://www.lolka.co.il/wp-content/uploads/2018/12/Screen-Shot-2018-12-28-at-15.46.29-e1546004840977.png",
autoplay: false,
sitekey: '0404',
category: "test src: "varffff1"
});
]]>
[1]: <![CDATA[
var playerInstance = new artiplayer('artimedia-player-0404-3',{
source: {type: "video/mp4", src: "https://www.0404.co.il/wp-content/uploads/2019/01/WhatsApp-Video-2019-01-07-at-08.33.38.mp4"},
poster: "https://www.0404.co.il/wp-content/uploads/2019/01/WhatsApp-Image-2019-01-07-at-08.38.27.jpeg",
autoplay: false,
sitekey: '0404',
category: "test"
});
]]>`
if len(re.FindStringIndex(str)) > 0 {
fmt.Println(re.FindString(str),"found at index",re.FindStringIndex(str)[0])
}
}
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/