Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isAvailableRealname(String realname) { String regEx = "^[\u4E00-\u9FA5]{2,4}+$"; Pattern pattern = Pattern.compile(regEx); Matcher matcher = pattern.matcher(realname); if (matcher.matches()) { return true; } return false; } }