我有一个模式,@@{}并给出一个字符串,我需要找出大括号之间的所有字符串.
示例:如果我的字符串是 Hi This is @@{first} and second is @@{second} along with third @@{third} string
我期望的输出是一个由元素组成的字符串数组:
first
second
third
Run Code Online (Sandbox Code Playgroud)
我的Java代码如下:
Pattern p = Pattern.compile("\\@\\@\\{(.+?)\\}");
Matcher match = p.matcher("Hi This is @@{first} and second is @@{second} along" +
"with third @@{third} string");
while(match.find()) {
System.out.println(match.group());
}
Run Code Online (Sandbox Code Playgroud)
但我得到的输出是
@@{first}
@@{second}
@@{third}
Run Code Online (Sandbox Code Playgroud)
请指导我如何获得所需的输出以及我正在做的错误