Given the following input string 3481.7.1071.html
I want to confirm that
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?
You can just factor it out:
(\d+\.)(\d+\.)*html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With