package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?<=SL{1}\d_)[0-9_]*|(?<=DM{1}\d\_)[0-9_]*`)
var str = `DM1_65_78109
SL1_78_72947
Input is DM1_813_1881
Input is DM2_793_1808
Input is DM1_SL1_609_604980
output should be 813_1881
output 609_604980
output 793_1808`
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/