import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "([ .\\w']+?)($|mp3|[s|S]\\d{1,}|\\(.*\\)|[A-Z]{2,}|\\W\\d{4}\\W?.*)";
final String string = "Better Call Saul S02E03 - Amarillo.mkv\n"
+ "dexter.New.Blood.mp3.S01E03.mkv\n"
+ "Rick.and.Morty.S05E01.720p.AMZN.WEBRip.x264-GalaxyTV.mkv\n"
+ "Black.Widow.mp4\n"
+ "Dexter.New.Blood.S01E01.mp4\n"
+ "Radin (2016) VFF [1080p] BluRay x264-PopHD.mkv\n"
+ "This Is the End 1080p MULTI 2013 BluRay x264.mkv\n"
+ "[ www.CpasBien.cm ] Marseille.2016.FRENCH.DVDRip.XviD-UTT.avi\n"
+ "(Complet)Le Pere Noel Est Une Ordure (Divx-Francais).avi\n"
+ "20.Ans.d.Ecart.2013.FRENCH.BRRIP.XviD-FUZION.avi\n"
+ "Blade.Runner.2049.2017.VOSTFR.FANSUB.1080p.WEB-DL.H264.AC3-TRUEDUKES.WwW.Torrent9.pe";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html