我正在尝试查找字符串是否仅包含数字和特殊字符。
我尝试了下面的代码,但没有用
String text="123$%$443";
String regex = "[0-9]+";
String splChrs = "-/@#$%^&_+=()" ;
if ((text.matches(regex)) && (text.matches("[" + splChrs + "]+"))) {
System.out.println("no alphabets");
}
Run Code Online (Sandbox Code Playgroud)