匹配中括号里的内容 []
String str = "[111]asdq[你好]是我[hello]哈哈[hehe]";
// String str = "我是[001]真心求救的[002],你能帮帮我吗";
Pattern pattern = Pattern.compile("\\[(.*?)\\]");
Matcher matcher = pattern.matcher(str);
while(matcher.find()){
System.out.println(matcher.group(1));
}
正则表达式收集
最新推荐文章于 2024-07-05 22:13:46 发布