package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`data:\s*(.*)`)
var str = `data: {"id":"cmpl-7UGNKhpHRPBvdilqMvoUgxGM2EiYO","object":"text_completion","created":1687447142,"choices":[{"text":"","index":0,"logprobs":null,"finish_reason":"stop"}],"model":"text-davinci-003"}
data: [DONE]
`
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/