in reply to Removing padding from numeric IP addresses

wouldn't s/(\.|^)0+/$1/g do the same thing ? 8-{Q}

update: hehe, lemming had a good point in CB, i forgot about the ^ :) corrected.

update2: coyotte also gets a good point in his reply, so here is another update :)

s/(\.|^)0{1,2}/$1/g

update3: and still, our great tye discovered another bug :) and yes, his solution is ofc good (s/(\.|^)\b0+\B/$1/g). ah, for the record, ofc that i like coyotte's solution 2, is the nicest :)

--
AltBlue.

  • Comment on Re: Removing padding from numeric IP addresses

Replies are listed 'Best First'.
Re: Re: Removing padding from numeric IP addresses
by Coyote (Deacon) on Jan 27, 2001 at 05:11 UTC
    It does until you run into an address like 192.168.010.000. Which ends up as 192.168.10. after you run it through the regex above.

    ----
    Coyote

(tye)Re: Removing padding from numeric IP addresses
by tye (Sage) on Jan 27, 2001 at 05:24 UTC

    Similar problem for update2, 1.2.3.0 doesn't work. I think that s/\b0+\B//g whould work. But I kinda like the original solution as it is easy to read and it is easy to code it correctly.

            - tye (but my friends call me "Tye")