is Chinese By Name in regex - Java Internationalization

Java examples for Internationalization:Chinese

Description

is Chinese By Name in regex

Demo Code


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

public class Main {
    public static void main(String[] argv) throws Exception {
        String str = "java2s.com";
        System.out.println(isChineseByName(str));
    }//from www. ja  v a 2s. c om

    public static boolean isChineseByName(String str) {
        if (str == null) {
            return false;
        }
        String reg = "\\p{InCJK Unified Ideographs}&&\\P{Cn}";
        Pattern pattern = Pattern.compile(reg);
        return pattern.matcher(str.trim()).find();
    }
}

Related Tutorials