package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)[^:]*: Input Traffic(.*)`)
var str = `MDS9706-1: Input Traffic fc1/12 - HOST12-HBA2
MDS9999-1: Input Traffic fc1/12 - HOST12-HBA2
abc-123: Input Traffic fc1/12 - HOST12-HBA2
1: Input Traffic fc1/12 - HOST12-HBA2
This will match: Input Traffic fc1/12 - HOST12-HBA2
This_wont_be_matched Input Traffic fc1/12 - HOST12-HBA2`
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/