package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)[[:blank:]]*+(?:[\[\(].*[\]\)][[:blank:]]*+)?(.*?)[[:blank:]\[\(]*+([1-2]\d{3}).*
`)
var str = `2 Fast 2 Furious [2003] [SD]
2 Fast 2 Furious (2003) [SD]
2 Fast 2 Furious ((2003) [SD]
A Goofy Movie (1995) (HD) (720p)
[test]A Goofy Movie (1995) (HD) (720p)
(test) A Goofy Movie (1995) (HD) (720p)
2 Fast 2 Furious 2003
2 Fast 2 Furious 2003
The Lion King 2- Simba's Pride (1998) (HD) (1080p)
The.Grand.Budapest.Hotel.2014.1080p.BluRay.x264-BLOW
Another.Earth.2011.LIMITED.720p.BluRay.X264-AMIABLE
The.Green.Mile.1999.720p.BluRay.x264-HDCLASSiCS
The Road 2009 Bluray DTS 720 p - TRiNiTY
Dead Poets Society (1989) 720p Blu-ray x264 DTS MSubs [DDR]
Garden.State.2004.720p.BluRay.X264-AMIABLE
`
var substitution = "\1 (\2) \3"
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/