import java.util.Scanner;
import java.util.regex.Pattern;
public class Test {
public static void main(String[] args) {
Scanner can = new Scanner(System.in);
String ss = can.nextLine();
String regEx = "[一-龥]";
Pattern p = Pattern.compile(regEx);
int num = 0;//汉字长度
for(int i=0;iif(p.matches(regEx, ss.substring(i, i + 1))){
num++;
}
}
if(num<2){
System.out.println("输入的中文不足两个");
}else{
System.out.println("满足");
}
}
}
....这回题终于看明白.........
^\w*?[\u4e00-\u9fa5]\w*?[\u4e00-\u9fa5]\w*?$
import java.util.Scanner;
import java.util.regex.Pattern;
public class Test {
public static void main(String[] args) {
Scanner can = new Scanner(System.in);
String ss = can.nextLine();
String regEx = "[\u4e00-\u9fa5]";
Pattern p = Pattern.compile(regEx);
int num = 0;//汉字长度
for(int i=0;i
num++;
}
}
if(num<2){
System.out.println("输入的中文不足两个");
}else{
System.out.println("满足");
}
}
}
....这回题终于看明白.........