package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?mi)^(?=\S{8,20}$)(?=\D*\d)(?![0-9_]).{6,18}?(.)\1$`)
var str = `+234567899
a_1de*Gg
xy1Me*__
!41deF_hij2lMnopq3ss
C234567890123$^67800
*5555555
sDF564zer""
!!!!!!!!!4!!!!!!!!!!
abcdefghijklmnopq9ss
a_1+Eff
B41def_hIJ2lmnopq3stt
abCDefghijklmnopqrss5
A_4 e*gg
__1+Eff
841DEf_hij2lmnopq3stt
a_1+eFg
b41DEf_hij2lmnopq3st
abCDefghijklmnopqrss
abcdef+++dF
!!!!!!!!!!!!!!!!!!!!
`
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/