title: how to get the array of strings that are inside curly braces in the source string in java
body: <p>There is a string object in java with its contents as:</p>
  
  <pre><code>String sourceString="This {is} a sample {string} that {contains} {substrings} inside curly {braces}";
  </code></pre>
  
  <p>I want the array of string with its contents as: <code>{is},{string},{contains},{substrings}{braces}</code> </p>
  
  <p>Following is the code that I wrote to get the result but the output I am getting is:</p>
  
  <pre><code>"{is} a sample {string} that {contains} {substrings} inside curly {braces}"
  </code></pre>
  
  <p>So, basically it is taking all the characters that are in between the first open curly braces and last closing curly braces.</p>
  
  <pre><code>// Source string
  String sourceString="This {is} a samle {string} that {contains} {substrings} inside curly {braces}";
  
  // Regular expression to get the values between curly braces (there is a mistake, I guess)
  String regex="\\{(.*)\\}";
  Matcher matcher = Pattern.compile(regex).matcher(sourceString);
  
  while (matcher.find()) {
      System.out.println(matcher.group(0));
  }
  </code></pre>