import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^(?!NOT FOUND \\*\\*\\*\\*\\* ).*$";
final String string = "a68ebf048cb21948ae814f88f8573267 *Torrented Movies\\Battlestar Galactica\\Season 1\\Video Files\\Battlestar.Galactica.s01e03.Bastille.Day.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL\\Battlestar.Galactica.s01e03.Bastille.Day.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL.part23.rar\n"
+ "143bc5637fca8831800682da24fabdbe *Torrented Movies\\Battlestar Galactica\\Season 1\\Video Files\\Battlestar.Galactica.s01e03.Bastille.Day.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL\\Battlestar.Galactica.s01e03.Bastille.Day.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL.part24.rar\n"
+ "eecbe9a184700963a09a3dc6486d1f72 *Torrented Movies\\Battlestar Galactica\\Season 1\\Video Files\\Battlestar.Galactica.s01e03.Bastille.Day.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL\\Battlestar.Galactica.s01e03.Bastille.Day.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL.part25.rar\n"
+ "51f6341b48d44788775ee676e9fd106a *Torrented Movies\\Battlestar Galactica\\Season 1\\Video Files\\Battlestar.Galactica.s01e03.Bastille.Day.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL\\Battlestar.Galactica.s01e03.Bastille.Day.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL.sfv\n"
+ "NOT FOUND ***** Torrented Movies\\Battlestar Galactica\\Season 1\\Video Files\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL.part01.rar\n"
+ "NOT FOUND ***** Torrented Movies\\Battlestar Galactica\\Season 1\\Video Files\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL.part02.rar\n"
+ "NOT FOUND ***** Torrented Movies\\Battlestar Galactica\\Season 1\\Video Files\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL.part03.rar\n"
+ "NOT FOUND ***** Torrented Movies\\Battlestar Galactica\\Season 1\\Video Files\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL.part04.rar\n"
+ "NOT FOUND ***** Torrented Movies\\Battlestar Galactica\\Season 1\\Video Files\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL.part05.rar\n"
+ "NOT FOUND ***** Torrented Movies\\Battlestar Galactica\\Season 1\\Video Files\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL\\Battlestar.Galactica.s01e04.Act.Of.Contrition.iNTERNAL.WS.DVDRip.XviD-MEDiEVAL.part06.rar\n";
final String subst = "";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
// The substituted value will be contained in the result variable
final String result = matcher.replaceAll(subst);
System.out.println("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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html