Java regex issue to get data in the brackets : <p>I want to get the data from String "Max(percentage(%))" or "Max(percentage)", what i need to get is "percentage(%)" or "percentage" in the brackets. I want to use one regex achieve the goal. Can someone help me? Below is my code:</p>

<pre><code>String str = "Max(percentage)";
Pattern pattern = Pattern.compile("(?&lt;=\\()(.+?)(?=\\))");

String str = "Max(percentage(%))";
Pattern pattern = Pattern.compile("(?&lt;=\\()(.+?)(?&lt;=\\))");
</code></pre>
