package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(\d{8}_\d{7}_)(?:CUPS[^_]+_)?(\S+)$`)
var str = `12345678_1234567_wgewgg_ewgewgw_gwgw_gwg
12345678_1234567_CUPS-Error_hgerhrh_herhr_herhe_heh`
var substitution = "$1CUPS-ERROR_$2"
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/