package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?i)\[\[file:(.*?(?:\.jpg|\.gif|\.bmp|\.png))(?:\||]).*`)
var str = `[[File:EDI.png|thumb|304x304px|none]]
[[File:RMS Home screen.png|thumb|none]]
[[File:ClipCapIt-170110-133309.PNG]]
[[file:send-rec.jpg|thumb|none]]
[[file:send-rec.12412.2.123.jpg|thumb|none]]
[[file:send-rec.12412.2.123.jpg|thumb|none]]
[[file:send-rec.12412.2.123.not-jpg|thumb|none]]`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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/