import java.util.Date;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.text.SimpleDateFormat;
public class Main {
String filename
= "19882012ABCseptemberDEF03HIJ12KLM0156_249.zip"; String regex
= "(.*?)([0-9]{4})([^0-9]*?)([a-z]+)(.*?)([0-9]{2})(.*?)([0-9]{2})(.*?)([0-9]{4})_([^.]+)[.]zip"; Matcher m = Pattern.compile(regex).matcher(filename);
if (m.matches()) {
System.
out.
println("it does match"); String dateString
=m.
group(2) + "-" + m.
group(4) + "-" + m.
group(6) + " " + m.
group(8) + m.
group(10); System.
out.
println("extracted: " + dateString
); // here you go with your date
} else {
System.
out.
println("it does not match"); }
}
}
aW1wb3J0IGphdmEudXRpbC5EYXRlOyAgCmltcG9ydCBqYXZhLnV0aWwucmVnZXguUGF0dGVybjsKaW1wb3J0IGphdmEudXRpbC5yZWdleC5NYXRjaGVyOyAKaW1wb3J0IGphdmEudGV4dC5TaW1wbGVEYXRlRm9ybWF0OwoKcHVibGljIGNsYXNzIE1haW4geyAKICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgdGhyb3dzIEV4Y2VwdGlvbiB7CiAgICAgIFN0cmluZyBmaWxlbmFtZSA9ICIxOTg4MjAxMkFCQ3NlcHRlbWJlckRFRjAzSElKMTJLTE0wMTU2XzI0OS56aXAiOwpTdHJpbmcgcmVnZXggPSAiKC4qPykoWzAtOV17NH0pKFteMC05XSo/KShbYS16XSspKC4qPykoWzAtOV17Mn0pKC4qPykoWzAtOV17Mn0pKC4qPykoWzAtOV17NH0pXyhbXi5dKylbLl16aXAiOwpNYXRjaGVyIG0gPSBQYXR0ZXJuLmNvbXBpbGUocmVnZXgpLm1hdGNoZXIoZmlsZW5hbWUpOwppZiAobS5tYXRjaGVzKCkpIHsKICAgU3lzdGVtLm91dC5wcmludGxuKCJpdCBkb2VzIG1hdGNoIik7CiAgICBTdHJpbmcgZGF0ZVN0cmluZyA9bS5ncm91cCgyKSArICItIiArIG0uZ3Jv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