8
2
I have a list of IP addresses in the following form:
010.125.015.013
010.125.153.012
010.125.012.135
I'm unable to execute ping with that form as windows thinks it's dotted octal form. I need to remove leading 0's after each dot.
It's not that simple as some of them have no leading 0's after dots at all and some of them have it only on last octet where some have it on third octet or both.
Unless there's a solution to force ping to interpret is as a dotted decimal IP address.
Can anyone help?
Thanks
2Shall we assume that you want to preserve a 0 in something like
123.234.000.276
? (Yes, bogus example.) – a CVn – 2015-06-23T20:08:12.880there has to be no 0's so in my example:
They need to be:
But when it's for example:
It has to be:
You can do this quite easily with the power of regex! Use this link to get started. The regex is as simple as
– Dudemanword – 2015-06-23T22:21:26.060^0
(match a zero at the beginning of the string!)2Removing leading zeros changes the IP, since the leading zero signifies octal numbers. – CodesInChaos – 2015-06-24T07:00:53.047
1@CodesInChaos In general yes. But the input looks like somebody simply prepended zeros to make each octet three digits long. It seems unlikely that somebody would also change the notation to be octal while performing that operation, besides it wouldn't work for octets in the range 64 to 99. I am guessing the task is to convert IPs from a non-standard notation with decimal numbers with leading zeros to a standard notation with decimal numbers without leading zeros. – kasperd – 2015-06-24T10:37:25.837