Regex to extract image name from HTML in Golang
Example
package main
import (
"fmt"
"regexp"
)
func main() {
str1 := `![](1.png)
![](2.png)
`
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 split a string on white-space?
Find element in a slice and move it to first position?
Golang download image from given URL
How to get struct variable information using reflect package?
Replace any non-alphanumeric character sequences with a dash using Regex
Regular expression to validate common Credit Card Numbers
Replace first occurrence of string using Regexp
Example: Fields and FieldsFunc from BYTES Package
How to check if a string contains a white space in Golang?
Find out how many logical processors used by current process