[Solved] Find the highest number between two literal strings using a Regular Expression
You can use this code to extract the numeric portion from the untitledNNN.java file name: Pattern p = Pattern.compile(“^untitled(\\d+)[.]java$”, Pattern.CASE_INSENSITIVE); for (String fileName : fileNames) { Matcher m = p.matcher(fileName); if (!m.find()) { continue; } String digits = m.group(1); … // Parse and find the max } Demo. Since you are OK with throwing an … Read more