import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^.*?:\\d\\d.*?\\n+|^\\n+$|^.*?replies.*?\\n+|^.*?\\d\\n+|^.*?:\\n+|^Last reply.*?\\n+";
final String string = "I recommend XMind 8 and not the newer XMind Zen (I have not tried XMind 2021). It is available here: xmind.net/download/xmind8 (edited) \n"
+ ":heavy_plus_sign:\n"
+ "1\n\n\n\n\n\n"
+ "5 replies\n"
+ "Last reply 24 hours agoView thread\n\n\n\n\n\n\n"
+ "Paul Holland 1:49 AM\n"
+ "If you need to convert to a PDF - you do not need to pay for the Pro version. On a Mac just print to a PDF. On a Windows machine use an app that lets you print to a PDF.\n"
+ ":point_up_2:\n"
+ "1\n\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