正如我在上面的标题中所提到的,我需要知道如何检查String中的每个字符,如下所示:
我一直在寻找确切的例子,但我找不到一个。
答案 0 :(得分:1)
按照以下步骤操作:
String s = "mystring";
s.length() < 3 // expression which says if it's smaller than 3.
s.matches(".*[0-9].*") //expression which says if there are digits in the string
s.matches("\b[^aeiouAEIOU ]+\b") //expression which says if there are no vovels
检查yourString
是否符合所有条件:
if (myString.length() < 3 && myString.matches(".*[0-9].*")
&& myString.matches("\b[^aeiouAEIOU ]+\b")) {
//matches all
}