On Wed, Jan 23, 2019 at 9:41 PM Grant Edwards <grant.b.edwa...@gmail.com> wrote:
>
> On 2019-01-23, Alexander Kapshuk <alexander.kaps...@gmail.com> wrote:
>
> > This any better? :-)
> >
> > echo '198.088.0.01
> > 198.088.062.01
> > 198.088.0.001' | sed -r 's/\.0+([^.0]+)/.\1/g'
>
> I guess it's 'better', but it's still broken:
>
> $ echo '003.4.5.6' | sed -r 's/\.0+([^.0]+)/.\1/g'
> 003.4.5.6
>
> This is not a good application for a regex.
>
> --
> Grant Edwards               grant.b.edwards        Yow! I have accepted
>                                   at               Provolone into my life!
>                               gmail.com
>
>
The OP stated that there were no leading zeros in the first octet of
the IP address, so that case did not need to be handled.

Reply via email to