小编Har*_*ini的帖子

检查字符串是否没有字母

我正在尝试查找字符串是否仅包含数字和特殊字符。

我尝试了下面的代码,但没有用

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)

java regex

2
推荐指数
2
解决办法
107
查看次数

标签 统计

java ×1

regex ×1