The next line should read:
if ( m.find() ) {
Are you doing that?
A few other issues: You're using .
to match the spaces surrounding the colon; if that's always supposed to be whitespace, you should use +
(one or more spaces) or \s+
(one or more whitespace characters). On the other hand, the dot between the digits is supposed to match a literal .
, so you should escape it: \.
Of course, since this is a Java String literal, you need to escape the backslashes: \\s+
, \\.
.
You don't need the square brackets around the r
, and if you don't want to match a |
in front of the number you should change [+|-]
to [+-]
.
While some of these issues I've mentioned could result in false positives, none of them would prevent it from matching valid input. That's why I suspect you aren't actually applying the regex by calling find()
. It's a common mistake.