package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?(DEFINE)(?<e>(?:.+\n\n|\Z))(?<i>(?:.+\n)))(?:(?:^.{4}|\G.*(?=.{6}$))\K(?=(?&i){5})|(?:^|\G.*(?=..$))\K(?=(?&i){3}(?&e))|(?:^.|\G.*(?=...$))\K(?=(?&i){2}(?&e))|(?:^..|\G.*(?=....$))\K(?=(?&i)(?&e)))..|...\K.+(?=(?:...\n\n|\Z))`)
var str = `aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
sdaffdsdfsdsfaadd
afdsafdsfssdsfdfs
afdsfdssdfdssfdsf
asfddsfafsdfdsdsf
asfdsdfafdsafasdf
hellohellohellohellohello
hellohellohellohellohello
hellohellohellohellohello
hellohellohellohellohello
hellohellohellohellohello
hellohellohellohellohello
`
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/