I'd like to parse the following sample string
foo :6
into two groups: Text and Number. The number group should be populated only if the character ":" precedes the number itself.
so:
foo 6 -> Text = "foo 6"
foo :6 -> Text = "foo", Number = "6"
The best I could come up with so far is
(?<Text>.+)(?=:(?<Number>\d+)h?)?
but that doesn't work because the first group greedily expands to the whole string.
Any suggestions?