Regex to extract image name from HTML in Golang
Example
package main
import (
"fmt"
"regexp"
)
func main() {
str1 := `
`
re := regexp.MustCompile(`]+\bsrc=["']([^"']+)["']`)
submatchall := re.FindAllStringSubmatch(str1, -1)
for _, element := range submatchall {
fmt.Println(element[1])
}
}
Output
1.png
2.png