package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?s)(TEST_CASE_NAME.*?:(.*?)\n.*?PRIORITY.*?:(?!P3)(\w\d).*?=cut)`)
var str = `=head2 Gen_001
TEST_CASE_NAME :GEN_001
PRIORITY :P0
RELEASE_INTRODUCED :7.4 AUTOMATED :YES
STEP_NAME : step1
STEP_DESC :Example desc for understanding STEP_RESULT :Example result for understanding
=cut
=head2 Gen_003
TEST_CASE_NAME :GEN_003
PRIORITY :P1
RELEASE_INTRODUCED :7.4 AUTOMATED :NO
STEP_NAME : step1
STEP_DESC :Example desc for understanding second testcase
STEP_RESULT :Example result for understanding second testcase
=cut
=head2 Gen_004
TEST_CASE_NAME :GEN_004
PRIORITY :P3
RELEASE_INTRODUCED :7.4 AUTOMATED :NO
STEP_NAME : step1
STEP_DESC :Example desc for understanding third testcase
STEP_RESULT :Example result for understanding third testcase
=cut`
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/