我试图找出字符串是否只有数字和特殊字符。
我试过下面的代码,但它不工作
String text="123$%$443";
String regex = "[0-9]+";
String splChrs = "-/@#$%^&_+=()" ;
if ((text.matches(regex)) && (text.matches("[" + splChrs + "]+"))) {
System.out.println("no alphabets");
}
LEATH
慕森王
明月笑刀无情
忽然笑
相关分类