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 to extract domain from URL
Regular expression to extract numbers from a string in Golang
Regular expression to extract text between square brackets
How to remove symbols from a string in Golang?
Regular expression to validate email address
Regular expression to validate common Credit Card Numbers