I am trying to match the following strings:
9
9.
9.5
.5
This is what I’ve produced so far to accomplish this:
(?<acreage>(?(\d+)((\.\d*)?)|(\.\d+)))
When I pass in 9.5, it returns NULL and .5 for acreage. I need it to pass back 9.5. What am I doing wrong?
So you have four situations:
xx.yx..ySo here you go:
You can get rid of either of the last two possibilities by making digits in the first group optional, but not both. For instance:
Or, with a match group: