package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)[a-zA-Z0-9\-\_]*\.[a-zA-Z0-9\-\_]*\.\w{1,3}(\.\w{1,3})?`)
var str = `
service.mensfitness.co.uk
updates.mensfitness.co.uk
promo.mensfitness.co.uk
deals.mensfitness.co.uk
subs.mensfitness.co.uk
service.healthandfitnessoneline.co.uk
updates.healthandfitnessoneline.co.uk
promo.healthandfitnessoneline.co.uk
deals.healthandfitnessoneline.co.uk
subs.healthandfitnessoneline.co.uk
service.custompc.co.uk
updates.custompc.co.uk
promo.custompc.co.uk
deals.custompc.co.uk
subs.custompc.co.uk
service.digitalslrphoto.com
updates.digitalslrphoto.com
promo.digitalslrphoto.com
deals.digitalslrphoto.com
subs.digitalslrphoto.com
`
var substitution = "'\g<0>'"
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/