Pattern pattern = Pattern.compile("^([a-zA-Z0-9]*)_(\\d*)?_?(.*)-\\d*_.*$");
Matcher m = pattern.matcher(resourceFile.getName());
if (m.find()) {
String destinationNickname = m.group(1);
String jobnumber = m.group(2);
String originalFileName = m.group(3);
}
Test your regex with this site: http://www.regexplanet.com/simple/index.html
No comments:
Post a Comment