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 filename from given path in Golang
Regular expression to validate phone number
Regular expression to extract text between square brackets
How to extract text from between html tag using Regular Expressions in Golang?
Regular expression to extract all Non-Alphanumeric Characters from a String
How to replace emoji characters in string using regex in Golang?