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
How to get Dimensions of an image type jpg jpeg png or gif ?
How to use a mutex to define critical sections of code and fix race conditions?
Different ways to validate JSON string
How to get the current date and time with timestamp in local and other timezones ?
Example: How to use ReadAtLeast from IO Package in Golang?
How to check UPPERCASE characters in a string in Golang?