package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)<metaData\s+key="([^"]+)">((?!<\/metaData>).+)<\/metaData>`)
var str = ` <metaDataSet>
<metaData key="DocName">mm1266505-20180330195251.txt</metaData>
<metaData key="TARGET">Brazil BES</metaData>
<metaData key="com.ibm.wmqfte.OriginatingUser">eimb@CORPWEB</metaData>
<metaData key="com.ibm.wmqfte.OriginatingHost">B051S317.jci.com</metaData>
<metaData key="com.ibm.wmqfte.TransferId">414d512050445053514d513031202020770fbe5aacf88f20</metaData>
<metaData key="com.ibm.wmqfte.Priority">0</metaData>
</metaDataSet>
`
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/