您的位置:首页 > 移动开发 > 微信开发

小程序-----输出字符串中的中文字符

2015-09-07 23:16 603 查看
今天笔试的时候遇到的一道试题,当时就知道使用正则表达式检查,但是就是不知道具体的实现,好多东西东是这样,导致笔试都没有过,尴尬。。。。。。。。。。。。。

现在把它写出来,没事多总结。

--------------------------------------------------------------------------------------------------------------------------------------------------------

import java.util.regex.Matcher;

import java.util.regex.Pattern;

public class test4 {

public static void main(String[] args) {

String test = "面试dwe顺利dwe2dfw2we!ewefnw";

Pattern p = Pattern.compile("([\u4e00-\u9fa5]+)");

Matcher m = p.matcher(test);

String s = null;

while(m.find()){

s=m.group(0);

System.out.print(s);

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: