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
Create and Print Multi Dimensional Slice in Golang
How to Unmarshal nested JSON structure?
Example of Sscan vs Sscanf vs Sscanln from FMT Package
Closures Functions in Golang
How to convert Colorful PNG image to Gray-scale?
How to set, get, and list environment variables?
How do you write multi-line strings in Go?
Example: How to use ReadAtLeast from IO Package in Golang?
Simple example of Map initialization in Go
How to concatenate two or more slices in Golang?