package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)((\d\d:){2}\d\d,\d\d\d| --> )+(?=(?:$\n.+)+chemical)`)
var str = `"1
00:01:46,356 --> 00:01:49,893
What is this? It's blue.
2
00:01:50,794 --> 00:01:54,998
We used a different chemical process,
but it is every bit as pure.
3
00:01:55,199 --> 00:01:58,267
It may be blue, but it's the bomb."`
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/