package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(?<flag>#+)\s*(?<content>.*?)\s*$`)
var str = `# The quick brown (1)
## fox jumps (1a)
###over (1a1)
###the (1a2)
## lazy dog (1b)
# Foo bar (2)
# Baz biz (3)
##buzz (3a)
##booz (3b)
# Lorem ipsum (4)
## `
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/