Use "(.+?)...
to receive the shortest sequence (without digit). Or better yet "(\\D+)...
.
Use (\\d+)
instead of (\\d)+
so that m.group(i)
is the entire string of digits.
No need to use a null check on the groups, maybe you intended an optional prefix: (\\D*)
.
Did you intend find()
or should it match the entire string: matches()
?