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
Most Helpful This Week
Regular expression for matching HH:MM time format in Golang
How to remove symbols from a string in Golang?
How to replace emoji characters in string using regex in Golang?
Regular expression to validate email address
Regular expression to extract text between square brackets
Regular expression to extract numbers from a string in Golang