title: Java Regex: Grouping consecutive 1 or 0 in a binary string
body: <p>I want to capture all the consecutive groups in a binary string</p>
  
  <pre><code>1000011100001100111100001
  </code></pre>
  
  <p>should give me</p>
  
  <pre><code>1
  0000
  111
  0000
  11
  00
  1111
  0000
  1
  </code></pre>
  
  <p>I have made <code>([1?|0?]+)</code> regex in my java application to group the consequential 1 or 0 in the string like <code>10000111000011</code>. 
  But when I run it in my code, <strong>there is nothing in the console printed:</strong></p>
  
  <pre><code>String name ="10000111000011";
      regex("(\\[1?|0?]+)" ,name);
  
      public static void regex(String regex, String searchedString) {
  
          Pattern pattern = Pattern.compile(regex);
          Matcher regexMatcher = pattern.matcher(searchedString);
          while (regexMatcher.find()) 
              if (regexMatcher.group().length() &gt; 0)
                  System.out.println(regexMatcher.group());
      }
  </code></pre>
  
  <p>To avoid syntax error in the runtime of regex, I have changed the <code>([1?|0?]+)</code> to the <code>(\\[1?|0?]+)</code></p>
  
  <p><strong>Why there is no group based on regex?</strong></p>