import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^[^\\]\\n]+\\]:[ \\t]+";
final String string = "Annotations of download.truelaunchbar.com\n"
+ "highlight [page 1]: True Launch Bar\n"
+ "highlight [page 8]: Creating shortcuts using Drag&Drop\n"
+ "highlight [page 9]: Creating plugins\n"
+ "highlight [page 11]: create a virtual folder, click on the “Browse…\n"
+ "highlight [page 12]: True Launch Bar supports all icon sizes. By default,\n\n"
+ "Highlight [133]: Click Options to select additional options for controlling which target items will be processed. To process all the files in subfolders of each target folder, mark the Search Nested Folders checkbox.\n\n"
+ "Underline [133]: You can also choose to process only text files or to process all file types. If you have graphics or other types of files in the target folders, you should restrict processing to only text files. This setting works in addition\n\n"
+ "Text [133]: testing";
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