On Mon, 25 Oct 2004, Khairul Azmi wrote: > Can somebody help me how to remove the trailing zero from an ip address > > $ip_add = "010.200.020.000"; > > The output should be "10.200.20.0"; > I''ve been trying many regex techniques but still unsuccessful.
It's probably possible to do this other ways, but oh well: $ perl -le '$ip_add = "010.200.020.000"; $ip_add =~ s/0*([0-9]+)/$1/g; print $ip_add' 10.200.20.0 $ So the statement to use (as I'm approaching it) is: $ip_add =~ s/0*([0-9]+)/$1/g; -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>