package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?<=Code:).*Distribution\s([\d.,]+)(?=\n)`)
var str = `Code: 210 - Test 1 - Distribution
267745 Vis - Branch Deposit 3/10/2021 2,000.00
468040 v- Branch Deposit 2/10/2021 1,700.00
586075 Visa 3/3/2021 555.48
502490 Vis 3/4/2021 1,835.51
403195 Vis 3/4/2021 2,033.56
500230 Vis 3/4/2021 651.29
Code: 210 - Test - Distribution 8,775.84
Code: 230 - Greenville - Distribution
853955 Clearing 2/1/2021 77.50`
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/