title: How to grab string between square brackets and exclude if it is only a number
body: <p>I am trying to create a regex that will capture string between the square brackets, and if there is a number like (1234) then that should be excluded</p>
  <p>I am using the regex</p>
  <pre><code>\[(.*?)\]
  </code></pre>
  <p>Suppose the sample data is</p>
  <pre><code>requests[45180], indices[movies]
  </code></pre>
  <p>In this case, I get the output as :</p>
  <pre><code>[45180]
  [movies]
  </code></pre>
  <p>But my expected output is :</p>
  <pre><code>movies
  </code></pre>
  <p><strong>Code:</strong></p>
  <pre><code>import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  import java.util.regex.Matcher;
  import java.util.regex.Pattern;
  
  public class RegexMatcher {
      private static String REGEX = &quot;\\[(.*?)\\]&quot;;
      private static String NUMBERS_REGEX = &quot;\\d+&quot;;
      private static List sampleData = Arrays.asList(&quot;test from [a.b.v1.2.0.71-0] to [a.b.v1.2.0.73-0]&quot;,
              &quot;requests[45180], indices[movies]&quot;);
  
      public static void main(String[] args) {
          Pattern pattern = Pattern.compile(REGEX);
          Pattern numberPattern = Pattern.compile(NUMBERS_REGEX);
          for (Object data : sampleData) {
              List&lt;String&gt; indices = new ArrayList&lt;&gt;();
              Matcher matcher = pattern.matcher(data.toString());
  
              while (matcher.find()) {
                  String index = matcher.group().replaceAll(&quot;[\\[\\]']+&quot;, &quot;&quot;);
                  Matcher numberMatcher = numberPattern.matcher(index);
                  if (!numberMatcher.matches())
                      indices.add(index);
                  
              }
              if (indices.size() &gt; 0)
                  System.out.println(&quot;Indices: &quot; + indices);
          }
      }
  }
  </code></pre>
  <p>Can anyone please help me resolve this issue?</p>