Removing Leading Zero from IP Addresses

by Mar 27, 2013

Here is another (and very solid) approach to remove leading zeroes from an IP address using a regular expression:

'010.012.000.101' -replace '\b0+\B' 

It looks for one or more "0" following a word boundary (\b) and not followed by a word boundary (\B), and removes those.

Twitter This Tip! ReTweet this Tip!