android正则表达式获取字符串ip及端口复习

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/generallizhong/article/details/77161650

时间长了很简单的两句代码都忘记了,这里复习一下

就以String mipdz=http://10.0.0.132:40392/:Service为例

Pattern p1 = Pattern.compile("(\\d+\\.\\d+\\.\\d+\\.\\d+)\\:(\\d+)");
				Matcher m1 = p1.matcher(mipdz);
				// 将符合规则的提取出来

				while (m1.find()) {
                                   //ip地址
					mip.setText(m1.group(1));
                                        //端口
					mipdkedxt.setText(m1.group(2));

				}


猜你喜欢

转载自blog.csdn.net/generallizhong/article/details/77161650