There is a space in your test String but your regex doesn't allow that.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
The space is because I do not know how to make it look proper in my post above. If I do not leave a space and post it here, it gets shown up as its original character. You can take it as such that there is no space in my regex.
Matcher.find() prints me true. But is there a way to extract the groups? I need those sequences as an array for checking against a predefined list. I tried mat.groupCount() and it gave me 0.
Joe Harry wrote:Matcher.find() prints me true. But is there a way to extract the groups? I need those sequences as an array for checking against a predefined list. I tried mat.groupCount() and it gave me 0.
If you only want the decimal part then put brackets '( and ') round the [0-9]+ and use mat.group(1) .
You will keep banging your head until you spend some time learning about regular expression and Java's Pattern and Matcher classes.