let's say I have a string.
String str = "Hello6 9World 2, Nic8e D7ay!";
Matcher match = Pattern.compile("\\d+").matcher(str);
the line above would give me 6, 9, 2, 8 and 7, which is perfect!
But if my string changes to..
String str = "Hello69World 2, Nic8e D7ay!";
note that the space between 6 and 9 is removed in this string.
and if I run..
Matcher match = Pattern.compile("\\d+").matcher(str);
it would give me 69, 2, 8 and 7.
my requirement is to extract the single digit numbers only. here, what I need is 2, 8, 7 and omit 69.
could you please help me to improve my regex? Thank you!