Actually the real problem is that the following should match
2.9
2.9.1
2.9.2
and so on
3.1
3.1.1
3.2.1
so from 3 onwards any digit could match
but for ones starting with 2, the only digit allowed next is 9
I would write a regular expression that matches only numbers that begin with 2, and then write a separate one that matches only numbers beginning with 3. I believe you can then combine them with a boolean or operator.