Regex question: Why isn't this matching?

Posted by AllenG on Stack Overflow See other posts from Stack Overflow or by AllenG
Published on 2010-05-17T18:27:18Z Indexed on 2010/05/17 18:30 UTC
Read the original article Hit count: 402

Filed under:
|

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

When it runs, it matches the 6.00 (correctly) which my logic then trims by one zero to turn into 6.0. The regex then runs again (or should) but fails to pick up the 6.0.

I'm by no means an expert on Regex, but my understanding of my expression is that it's looking for a decimal with 1 or more optional (so, really zero or more) digits prior to one or more zeros which are then followed by any non-digit character or the line break. Assuming that interpretation is correct, I can't see why it wouldn't match on the second pass. For that matter, I'm not sure why my Regex.Replace isn't matching the full 6.00 on the first pass and removing both of the trailing zeros...

Any suggestions?

© Stack Overflow or respective owner

Related posts about regex

Related posts about c#4.0