ip=ip.repalceAll("0*(\\d{3})","$1");————
\d代表0-9的数字,由于\转义,用\\d表示,
\\d{3}代表数字出现恰好三次
所以ip=ip.repalceAll("0*(\\d{3})","$1")的意思就是把数字保留3未而如果前面还有1个或多个0的话把前面的0去掉(0*)
运行结果如下:
00192.0068.001.00254 00198.0068.0036.00102 0010.0010.0010.0010 002.002.002.002 008.0010.0026.0053
192.068.001.254 198.068.036.102 010.010.010.010 002.002.002.002 008.010.026.053
|