package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)([^\/]+)\/?
`)
var str = `https://www.ducati.com/es/es/motocicletas/monster/monster-797
https://www.ducati.com/es/es/motocicletas/diavel/diavel-1260
https://www.ducati.com/es/es/motocicletas/hypermotard/hypermotard
https://www.ducati.com/es/es/motocicletas/hypermotard/hypermotard-950
https://www.ducati.com/es/es/motocicletas/monster/monster-1200
https://www.ducati.com/es/es/motocicletas/monster/monster-1200-25-anniversario
https://www.ducati.com/es/es/motocicletas/monster/monster-1200r
https://www.ducati.com/es/es/motocicletas/monster/monster-797
https://www.ducati.com/es/es/motocicletas/monster/monster-821
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-1260
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-1260-enduro
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-950
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-enduro
https://www.ducati.com/es/es/motocicletas/panigale/1299-panigale-r-final-edition
https://www.ducati.com/es/es/motocicletas/panigale/959-panigale
https://www.ducati.com/es/es/motocicletas/panigale/panigale-v4
https://www.ducati.com/es/es/motocicletas/panigale/panigale-v4-r
https://www.ducati.com/es/es/motocicletas/supersport/supersport
https://www.ducati.com/es/es/motocicletas/xdiavel/xdiavel
`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/