package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(^(?:\/(_next\/data\/[^\/]{1,}))?(?:\/(?<i18n_locale>(?!_next\/)(en|de)))(?<user_matcher_from_i18n_pattern>\/((?!api|_next\/static|_next\/image|favicon.ico|sitemap.xml|robots.txt).*))(\.json)?[\/#\?]?$)|(^(?<user_matcher_from_base_matcher>\/((?!api|_next\/static|_next\/image|favicon.ico|sitemap.xml|robots.txt).*))[\/#\?]?$)`)
var str = `/api/some-api-route
/de/some-page-for-de-locale
/some-page-for-default-locale
`
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/