我有 2 个具有此类值的字符串:
String name = "Scripy";
String username = "adil";
当我用正则表达式检查这些字符串时,我得到了false价值:
if(name.matches("/[a-zA-Zа-яА-ЯёЁ ]+/")){
System.out.println("Name: true");
}else{
System.out.println("Name: false");
}
if(username.matches("/^[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*$/")){
System.out.println("Username: true");
}else{
System.out.println("Username: false");
}
结果:
I/System.out: Name: false
I/System.out: Userame: false
问题是什么?
Cats萌萌
相关分类