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

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于人编辑

你可能感兴趣的:(编程语言(java,php,c++))