package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)overdraftlog-[0-9]{14}.[0-9]{3}(.log$|.log.sha$)`)
var str = `overdraft-transactions_2020-06-19_10_20200620020000.csv
overdraft-transactions_2020-06-19_10_20200620020000.csv.sha1
overdraft-transactions_2020-06-20_6_20200621020000.csv
overdraft-transactions_2020-06-20_6_20200621020000.csv.sha1
overdraft-transactions_2020-06-21_6_20200622020000.csv
overdraft-transactions_2020-06-21_6_20200622020000.csv.sha1
overdraft-transactions_2020-06-22_7_20200623020000.csv
overdraft-transactions_2020-06-22_7_20200623020000.csv.sha1
overdraft-transactions_2020-06-23_6_20200624020001.csv
overdraft-transactions_2020-06-23_6_20200624020001.csv.sha1
overdraft-application_2020-06-19_0_20200620020000.csv
overdraft-application_2020-06-19_0_20200620020000.csv.sha1
overdraft-application_2020-06-20_0_20200621020000.csv
overdraft-application_2020-06-20_0_20200621020000.csv.sha1
overdraft-application_2020-06-21_0_20200622020000.csv
overdraft-application_2020-06-21_0_20200622020000.csv.sha1
overdraft-application_2020-06-22_0_20200623020000.csv
overdraft-application_2020-06-22_0_20200623020000.csv.sha1
overdraft-application_2020-06-23_0_20200624020001.csv
overdraft-application_2020-06-23_0_20200624020001.csv.sha1
overdraftlog-20201005122521.748.log
overdraftlog-20201005122521.748.log.sha
overdraftlog-20201006030000.749.log
overdraftlog-20201006030000.749.log.sha`
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/