62,635
社区成员




public static void main(String[] args) {
// TODO Auto-generated method stub
String str="中国d中国x";
String regex="[^a-z]*[a-z]+[^a-z]*x";
Pattern p=Pattern.compile(regex);
Matcher m=p.matcher(str);
if(m.matches()){
System.out.println(true);
}else{
System.out.println(false);
}
}
// 数字字母混合,我测试了,可以啊
String str = "0sd00e23s";
if (str != null && Pattern.compile("(?i)[a-z]").matcher(str).find()) {
// 有字母
System.out.println("YES");
}
public boolean hasAlpha(String s){
char[] string = s.toCharArray();
for(int i=0; i<string.length; i++){
if(Character.isLetter(string[i])){
return true;
}
}
return false;
}
String str="sdfsdfx";
String str2="sdfsf123z";
System.out.println(str.matches("[a-zA-Z]*"));
System.out.println(str2.matches("[a-zA-Z]*"));
System.out.println(str.endsWith("x"));
System.out.println(str2.endsWith("x"));