package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(?P<posting_date>\d{2}/\d{2}/\d{4})\s+(?P<transaction_date>\d{2}/\d{2}/\d{4})\s+(?P<description>[\w\s(),:]+?)\s+(?P<Amount>-?\d{1,3}(?:\s\d{3})*\.\d{2})\s+(?P<Balance>-?\d{1,3}(?:\s\d{3})*\.\d{2})$`)
var str = `26/01/2023 26/01/2023 Payment Received Z Kona 8 000.00 8 085.87
26/01/2023 26/01/2023 Banking App Payment: Sihle -2 000.00 6 085.87
26/01/2023 26/01/2023 Payment Fee -1.50 6 084.37
26/01/2023 26/01/2023 SMS Payment Notification Fee -0.25 6 084.12
26/01/2023 26/01/2023 Payment Received Z Kona 15 000.00 21 084.12
26/01/2023 26/01/2023 Payment Received Z Kona 1 500.00 22 584.12
26/01/2023 26/01/2023 Payment Received Z Kona 2 000.00 24 584.12
26/01/2023 26/01/2023 Banking App Transfer to Ms K Savings (1816578655) -18 500.00 6 084.12
`
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/