Remove leading zeros from IP Address with C#

The IP Address object will treat a leading zero as octal, so it should not be used to remove the leading zeros as it will not handle 192.168.090.009.

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/21510004-b719-410e-bbc5-a022c40a8369


Yes, there's a much better way than using regular expressions for this.

Instead, try the System.Net.IpAddress class.

There is a ToString() method that will return a human-readable version of the IP address in its standard notation. This is probably what you want here.