package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^((?:[^_]*_){5}[^_]*).*$`)
var str = `HTZ_2015_CS_SS5_cncenter_1020x200_AS2_10K.html
HTZ_2015_CS_SS5_cncenter_1020x200_AS2_10K.swf
HTZ_2015_CS_SS5_cncenter_1500x1000_160K_w1020.jpg`
var substitution = "$1"
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/