package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(?P<KEY>[^=#\s]+)=(?P<VALUE>.*)$`)
var str = `app=tcp/444
# Catchs only Key:app Value:tcp > should catch Key:app Value:tcp/444
catdt=Network-based
# Current result:
# catdt:'Network'
#
# Shoud be:
# catdt:'Network-based'
eventId=123123 externalId=11111
# Current result:
# eventId:'123123 externalId=11111'
#
# Should catch
# eventId: '123123'
# externalId: '111111'
src=2.3.4.5
# Current result:
# src:'2'
#
# Should catch
# src: '2.3.4.5'
eventAnnotationEndTime=1493293598\=aaa00
# Should be:
# eventAnnotationEndTime: '1493293598\=aaa00'
eventAnnotationEndTimeA=1493293598A\=aaa01
eventAnnotationEndTimeB=1493293598\=aaa02
# Should be:
# eventAnnotationEndTimeA: '1493293598\=aaa01'
# eventAnnotationEndTimeB: '1493293598\=aaa02'
sourceTranslatedZoneURI=/All Zones/ArcSight System/Private Address Space Zones/RFC1918: 172.3.0.0-172.3.255.255
# Should be:
# ourceTranslatedZoneURI: '/All Zones/ArcSight System'`
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/