`
wesker0918
  • 浏览: 41270 次
  • 性别: Icon_minigender_1
  • 来自: 山东->北京
社区版块
存档分类
最新评论

判断字符是否为中文

阅读更多
package cn.wangy.test;

import java.io.UnsupportedEncodingException;

public class Test {
	public static void main(String[] args) throws UnsupportedEncodingException {   
        // 判断字符是否为中文   
        String str = "`~!@#$%^&*()_+\\|/?.,<>abcdefghijklmnopqistuvwxyzABCDEFGHIJKLMNOPQISTUVWXYZ中国笢恅";   
        for (int i = 0; i < str.length(); i++) {   
            if (str.substring(i, i + 1).matches("[\u4e00-\u9fa5]")) {   
                System.out.println(str.substring(i, i + 1) + "为汉字");   
            } else {   
                System.out.println(str.substring(i, i + 1) + "不为汉字");   
            }   
        }   
    }   
}

 

分享到:
评论
1 楼 davidx 2009-07-21  
正则表达式

相关推荐

Global site tag (gtag.js) - Google Analytics