const regex = /[[:blank:]]*+(?:[\[\(].*[\]\)][[:blank:]]*+)?(.*?)[[:blank:]\[\(]*+([1-2]\d{3}).*
/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('[[:blank:]]*+(?:[\\[\\(].*[\\]\\)][[:blank:]]*+)?(.*?)[[:blank:]\\[\\(]*+([1-2]\\d{3}).*
', 'gm')
const 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
`;
const subst = `\1 (\2) \3`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions