I have a string like "portal100common2055"
.
I would like to split this into two parts, where the second part should only contain numbers.
"portal200511sbet104"
would become "portal200511sbet"
, "104"
Can you please help me to achieve this?
Like this:
Matcher m = Pattern.compile("^(.*?)(\\d+)$").matcher(args[0]);
if( m.find() ) {
String prefix = m.group(1);
String digits = m.group(2);
System.out.println("Prefix is \""+prefix+"\"");
System.out.println("Trailing digits are \""+digits+"\"");
} else {
System.out.println("Does not match");
}
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