1         String pattern = "\\{[^\\}]+\\}";  // [^\\}]表示除}以外的其他字符
 2         //  创建 Pattern 对象
 3         Pattern r = Pattern.compile(pattern);
 4 
 5         String str = "您好,{a||b||c},这里是{d||e||f}";
 6         // 现在创建 matcher 对象
 7         Matcher m = r.matcher(str);
 8         while (m.find()) {
 9             System.out.println(m.group());
10         }

打印为:

{a||b||c}
{d||e||f}

相关文章:

  • 2021-08-31
  • 2022-02-09
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
猜你喜欢
  • 2021-09-09
  • 2021-06-06
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
相关资源
相似解决方案