package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?:^
(?:
\( [^)]* \)
|
\p{Lu}+ (?>[ ]\p{Lu}+\b)*
(?>/\p{Lu}+(?>[ ]\p{Lu}+ \b)* )*
)
[ ]
)?
[^/\n]*+ \K .`)
var str = `Dogs/Cats/Mice
ANIMALS/SPECIES Dogs/Cats/Mice
(Animals/Species) Dogs/Cats/Mice
ANIMALS/SPECIES Dogs and Cats/Mice
BRITISH RECIPES/DESSERT pudding/rum baba/crumble
RECIPES/BRITISH DESSERT pudding/crumble`
var substitution = " or "
fmt.Println(re.ReplaceAllString(str, substitution))
}
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/