package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^([\d.]+)\s+PER\s+(.*?)(?:\sIn\s*(.+?))?(?:\s*DEAD.*)?$`)
var str = `1.0 PER Sample DEAD VOLUME 1
1.0 PER Request DEAD VOLUME 1
10.0 PER Empty Well In Column DEAD VOLUME 10
8.0 PER Empty Well In Row DEAD VOLUME 8
1.0 PER Sample
1.0 PER Request
10.0 PER Empty Well In Column`
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/