package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?<=SUBH2002078568)[\s\S]+?(?=SUBF2002078568)`)
var str = `HMT940040324
SUBH2002078568
2002078568{1:F01BANK MBI}{2:I940MAP}{4:
2002078568:20:20210420182417
2002078568:25:2002078568
2002078568:28C:00075
2002078568:60F:D210420IDR0,
2002078568:62F:D210420IDR0,
2002078568-}
SUBF2002078568
SUBH2003001298
2003001298{1:F01BANK MBI}{2:I940MAP}{4:
2003001298:20:20210420182417
2003001298:25:2003001298
2003001298:28C:00075
2003001298:60F:C210420IDR111520964,38
2003001298:62F:C210420IDR111520964,38
2003001298-}
SUBF2003001298
SUBH2002078568 // *Added this account from the top*
2002078568{1:F01BANK MBI}{2:I940MAP}{4:
2002078568:20:20210420182417
2002078568:25:2002078568
2002078568:28C:00075
2002078568:60F:D210420IDR0,
2002078568:62F:D210420IDR0,
2002078568-}
SUBF2002078568- // End
FMT9400000004`
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/