package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?<src_ip>\d{0,2}\.\d{0,2}\.\d{0,2}\.\d{0,2})\s(?<signture>%(?<product>ASA))-(?<version>(?<release>\d+)-(?<build>\d+)):`)
var str = `May 9 14:30:00 10.25.8.3 %ASA-6-302013: Built outbound TCP connection 1032748840 for MGM-CML-NON-LB-SRV-Log:10.25.3.21/9997 (10.25.3.21/9997) to MIT-IBMgmt-NW:10.70.21.165/4379 (10.70.21.165/4379)`
if len(re.FindStringIndex(str)) > 0 {
fmt.Println(re.FindString(str),"found at index",re.FindStringIndex(str)[0])
}
}
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/