这期内容当中小编将会给大家带来有关如何利用Java中的正则获取标签的数据,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

String str = "哈哈1111还是你牛11111 ";
String regStr = "(.*?)";
Pattern pattern = Pattern.compile(regStr);
if(str != null){
Matcher m = pattern.matcher(str);
while(m.find()){
String group = m.group(1);
System.out.println(group);
str = str.replaceAll(regStr, "***");
}
System.out.println(str);
}