pattern pattern = pattern.compile("@.+?(:|\\s)"); matcher matcher = pattern.matcher("@正则表达式:hello world,@正则表达式 helloworld"); system.out.println(matcher.replaceall("java"));
正则匹配@开始空格或结束
最新推荐文章于 2020-08-31 22:03:34 发布
pattern pattern = pattern.compile("@.+?(:|\\s)"); matcher matcher = pattern.matcher("@正则表达式:hello world,@正则表达式 helloworld"); system.out.println(matcher.replaceall("java"));