package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^([^:(,]*)\b`)
var str = `Boston (Boston University, Boston College, Bos...
Bridgewater (Bridgewater State College)[2]
Cambridge (Harvard University, Massachusetts I...
Chestnut Hill (Boston College)
The Colleges of Worcester Consortium:
Dudley (Nichols College)
Faribault, South Central College
Mankato (Minnesota State University, Mankato),...
Marshall (Southwest Minnesota State University...
Moorhead (Minnesota State University, Moorhead...
Morris (University of Minnesota Morris)[2]
Northfield (Carleton College, St. Olaf College...
North Mankato, South Central College
St. Cloud (St. Cloud State University, The Col...
St. Joseph (College of Saint Benedict)[2]
St. Peter (Gustavus Adolphus College)[2]`
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/