package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)\d{1,2}.\d{1,2}.20\d{2}`)
var str = `Example 1 (Colon)
Payee: John Smith
Account No: 145-567-981
Date: 19.01.2020
Time: 08:01
Email: JohnSmith@gmail.com
Example 2 (the dash)
John Smith - Payee
145 567 981 - Account No
19-01-2020 - Date
08:01 - Time
John.Smith@hotmail.com - Email
Example 3 (the dashes AND all one line of text)
Payee - John Smith - Account No - 145.567.9815 - Date - 19,1,2020 - Time - 08:01 - Email - John.Z.Smith@yahoo.com`
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/