package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)[^.]+\.(?=[^.]+$)`)
var str = `// hash starts with number
/css/app.style.7fef363d5a8c4ef2458c.css
/css/app.bundle.7fef363d5a8c4ef2458c.css
/css/app.chunk.7fef363d5a8c4ef2458c.css
/css/app.7fef363d5a8c4ef2458c.css
/css/loading-animation.7fef363d5a8c4ef2458c.css
// hash starts with letter
/css/app.style.b3bcb606396f0c96623a.css
/css/app.bundle.b3bcb606396f0c96623a.css
/css/app.chunk.b3bcb606396f0c96623a.css
/css/app.b3bcb606396f0c96623a.css
// no preceeding dot separated name before the hash
/css/loading-animation.b3bcb606396f0c96623a.css
/css/app.b3bcb606396f0c96623a.js`
var substitution = ""
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/