package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?i)республика\s*([\s\S]*?)\s*край\s*\(\s*область\s*\)\s*([^\n]*?)\s*\nрайон\s*([^\n]*?)\s*\nнас\.\s*пункт\s*([^\n]*?)\s*\n`)
var str = `Республика ХХХХХХХ
ХХХХХ
ХХХХХ
Край( область ) ХХХХХХ
Район ХХХХХХХХ
Нас.пункт ХХХХХХХХХ
РеспубликаХХХХХХХ
ХХХХХ
ХХХХХ
Край(область)ХХХХХХ
РайонХХХХХХХХ
Нас.пунктХХХХХХХХХ
`
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/