import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "-a----\\s{2,}[0-9]\\/[0-9]{1,}\\/201[0-9]\\s{1,}[0-9]{1,}:[0-9]{2} [AP]M\\s{2,}[0-9]{2,}\\s";
final String string = "-a---- 7/30/2017 4:28 PM 201 textfile1.txt\n"
+ "-a---- 6/9/2016 4:03 PM 44 textfile2.txt\n"
+ "-a---- 6/22/2017 12:10 PM 137 textfile3.txt\n"
+ "-a---- 6/6/2017 7:24 PM 8269721 otherfile.com\n"
+ "-a---- 3/11/2016 4:22 PM 3370 otherfile.bat";
final String subst = " Call Deletefile(MyMaster.ZSVCPATH'\\\\firmware\\\\";
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