c# 4.0 - Regex question: Why isn't this matching? -


I have the following regex: (? & Lt; = \. \ D +?) 0 + (? = \ D | $) I'm running it against a string with the following: SVC ~ NU ^ 0270 ~ 313.3 ~ 329.18 ~~ 10 ~~ 6.00:

When it moves, it matches 6.00 (correctly), on which my argument goes from zero to 6.0. Regex runs again (or should) again, but fails to pick up 6.0.

I do not mean any expert of Regex, but my understanding of my expression is that one is looking for a decimal with 1 or more alternate (hence, actually zero or more) points Or before more than one zero, which comes after any non-digit character or line break. It is understood that this interpretation is correct, I can not see why it will not match the second pass. For that matter, I'm not sure that my Regex.Replace is not matching with the full 6.00 on the first pass and removing both the back zero ...

Any suggestions?

+? The instrument "matches one or more, non-greedy". You probably think that it means the same as * , which means zero or more often matches your entire expression. The first expression should match at least once to match \ d , and now it is not for input 6.0

+? Change to * and the expression should work.


Comments