Given the following input string 3481.7.1071.html
I want to confirm that
- The string has 1 or more numbers followed by a period.
- The string ends in html.
Finally, I want to extract the left-most number (i.e. 3481).
My current regex is nearly there but I can't capture the correct group:
final Pattern p = Pattern.compile("(\\d++\\.)+html");
final Matcher m = p.matcher("3481.7.1071.html");
if (m.matches()) {
final String corrected = m.group(1)+"html"; // WRONG! Gives 1071.html
}
How do I capture the first match?