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