// 取出所有""中间的内容,正则如下
Pattern pattern1 = Pattern.compile("(?<=\")([\\S]+?)(?=\")");

这里取得是string中双引号中间的内容,可以根据需求自己修改,比如取[]中间的内容,正则可以修改成

(?<=\")([\\[]+?)(?=\]) 如果只匹配中文,可以改成(?<=\")([\u4e00-\u9fa5]+?)(?=\")
利用正则取出符合规则的代码如下
//要匹配的字符串
String str = "\"名称\",\"名称\",\"名称\",\"名称\",\"名称\",\"名称\",";
//进行匹配
Matcher matcherTime = pattern1.matcher(str);
//循环打印匹配出来的结果
while (matcherTime.find()) {
    System.out.println(matcherTime1.group());
}
                

 

相关文章:

  • 2022-01-18
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
  • 2021-08-27
  • 2021-09-10
相关资源
相似解决方案