学习过程中随手写的一些测试的代码,记录下来以备日后查看
也希望能给别人些许的帮助
System.out.println(".-".matches("[.-]*"));// true
System.out.println(".".matches("[.-]*"));// true
System.out.println("".matches("[.-]*"));// true
System.out.println("".matches("[\\w[.-]]*"));// true
System.out.println("".matches("[\\w[.-]]+"));// false
System.out.println("dfg_33.dd-ff@@".matches("[\\w[.-]]+@{1}"));// false
System.out.println("dfg_33.dd-ff".matches("[\\w[.-]]+@{1}"));// false
System.out.println("df@g_33.dd-ff@".matches("[\\w[.-]]+@{1}"));// false
System.out.println("dfg_33.dd-ff@".matches("[\\w[.-]]+@{1}[\\w[.-]]+"));// false
System.out.println("xxx_yy123-zz.hh@163."
.matches("[\\w[.-]]+@{1}[\\w[-]]+.\\w+"));// false
System.out.println("xxx_yy123zzhh@zh-logistics.com.cn"
.matches("[\\w[.-]]+@{1}[\\w[.-]]+[.]\\w+"));
System.out.println("xxx_yy123zzhh@zh-logistics.com.cn"
.matches("[\\w[.-]]+@[\\w[.-]]+\\.\\w+"));