package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)parent {[\s\S]*type.*[\s\S]*subtype.*[\s\S]*element.*[\s\S]*attributes.*[\s\S]*value testvalue.*[\s\S]*owner person1`)
var str = `parent {
type {
subtype TestSubType {
element TestElement {
attributes {
name testname;
description testdescription;
count 1234;
value testvalue;
}
owner person1;
}
}
subtype TestSubType2 {
element TestElement2 {
attributes {
name testname2;
description testdescription2;
count 2;
value 2
}
owner unknown;
}
}
}
}
`
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/