加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

利用正则表达式去提取特征汉字

发布时间:2020-12-14 01:23:19 所属栏目:百科 来源:网络整理
导读:public static void main(String[] args) throws IOException { String str = "本帖最后由henry.cao于昨日编辑此类信息也显示出来了"; BufferedReader in; Pattern pattern = Pattern.compile("([u672C|u5E16|u6700|u540E|u7531]){5}(.)*([u4E8E])(.)*(
public static void main(String[] args) throws IOException {
String str = "本帖最后由henry.cao于昨日编辑此类信息也显示出来了";
BufferedReader in;
Pattern pattern = Pattern.compile("([u672C|u5E16|u6700|u540E|u7531]){5}(.)*([u4E8E])(.)*(u7F16){1}(u8F91){1}");
in = new BufferedReader(new StringReader("本帖最后由***于***编辑此类信息也显示出来了"));
String s;
while ((s = in.readLine()) != null)
{
Matcher matcher = pattern.matcher(s);
if (matcher.find())
{
System.out.println(matcher.group());
}
}
in.close();

}


输出:本帖最后由henry.cao于人编辑

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读