String b = a.next();//校验地址中是否存在 “ip:端口号” (例如rtsp://admin:admin@192.168.30.98:554/media/video1 ) Pattern p = Pattern.compile("(\\d+\\.\\d+\\.\\d+\\.\\d+)\\:(\\d+)"); Matcher m = p.matcher(b);//将符合规则的提取出来 while(m.find()) { System.out....
结果为: ip:192.168.30.98 port:554