if Contain Chinese by Regex - Java Internationalization

Java examples for Internationalization:Chinese

Description

if Contain Chinese by Regex

Demo Code


//package com.java2s;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static final String chinesePart = "[\u4E00-\u9FA5]";

    public static boolean ifContainChinese(String str) {
        return find(chinesePart, str);
    }/* w w w .j  a v  a 2 s  . co  m*/

    public static boolean find(String regex, String str) {
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(str);
        return matcher.find();
    }
}

Related Tutorials