I have two possible patterns:
1.2 hello
1.2.3 hello
I would like to match 1
, 2
and 3
if the latter exists.
Optional items seem to be the way to go, but my pattern (\d)\.(\d)?(\.(\d)).hello
matches only 1.2.3 hello
(almost perfectly: I get four groups but the first, second and fourth contain what I want) - the first test sting is not matched at all.
What would be the right match pattern?