const regex = /([ .\w']+?)($|mp3|[s|S]\d{1,}|\(.*\)|[A-Z]{2,}|\W\d{4}\W?.*)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('([ .\\w\']+?)($|mp3|[s|S]\\d{1,}|\\(.*\\)|[A-Z]{2,}|\\W\\d{4}\\W?.*)', 'gm')
const str = `Better Call Saul S02E03 - Amarillo.mkv
dexter.New.Blood.mp3.S01E03.mkv
Rick.and.Morty.S05E01.720p.AMZN.WEBRip.x264-GalaxyTV.mkv
Black.Widow.mp4
Dexter.New.Blood.S01E01.mp4
Radin (2016) VFF [1080p] BluRay x264-PopHD.mkv
This Is the End 1080p MULTI 2013 BluRay x264.mkv
[ www.CpasBien.cm ] Marseille.2016.FRENCH.DVDRip.XviD-UTT.avi
(Complet)Le Pere Noel Est Une Ordure (Divx-Francais).avi
20.Ans.d.Ecart.2013.FRENCH.BRRIP.XviD-FUZION.avi
Blade.Runner.2049.2017.VOSTFR.FANSUB.1080p.WEB-DL.H264.AC3-TRUEDUKES.WwW.Torrent9.pe`;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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