1.为什么要用正则表达式 首先我们先来做一道题目:判断一个字符串是否由数字组成.代码示例如下: public class Test { public static void main(String[] args) { String str="5201314"; char[] chars = str.toCharArray(); boolean flag=true; for (int i=0;i<chars.length;i++){ if (chars[i]<'0'||cha
由于我需要用到java正则表达式提取地址中的ip和端口号,所以我就写了一个demo,测试一下,下面是demo public class Test0810_1 { public static void main(String[] args) { //通过控制板输入想要输入的地址,然后测试是否符合规则 Scanner a = new Scanner(System.in); String b = a.next(); //校验地址中是否存在 "ip:端口号" (例如rtsp://admin: