package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)[sS]ee, e\.g\.[^(]*\((\d*)\D+Cir[^(]*\((\d+)\D+Cir`)
var str = ` Here are three examples I WANT to match:
See, e.g., Smith v. U.S. (5th Cir. 2012); U.S. v. Sara (1st Cir. 2017).
See, e.g., Jefferson v. U.S. (D.C. Cir. 2012); U.S. v. Coolidge (10th Cir. 2017).
See, e.g., Lincoln v. Jones (9th Cir. 2012); U.S. v. Roosevelt (3d Cir. 2017).
Here are three examples I DO NOT WANT to match.
See, e.g., Smith v. U.S. (1st Cir. 2012); U.S. v. Sara (5th Cir. 2017).
See, e.g., Jefferson v. U.S. (10th Cir. 2012); U.S. v. Coolidge (D.C. Cir. 2017).
See, e.g., Lincoln v. Jones (3d Cir. 2012); U.S. v. Roosevelt (9th Cir. 2017).
`
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/