package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`([a-zA-Z\:]){4,100}([a-zA-Z0-9]{8}[:-]([a-zA-Z0-9]{4}[:-]){3}[a-zA-Z0-9]{12})`)
var str = []byte(`urn:vcloud:user:2998042f-b91d-4c16-9de8-7feaf5e711a8
`)
var substitution = []byte("")
var count = 1 // negative counter is equivalent to global case (replace all)
str = re.ReplaceAllStringFunc(str, func(s string) string {
if count == 0 {
return s
}
count -= 1
return re.ReplaceAllString(s, substitution)
})
fmt.Println(string(str))
}
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/