title: Zero-length matches in Java Regex
body: <p>My code : </p>
  
  <pre><code>Pattern pattern = Pattern.compile("a?");
  Matcher matcher = pattern.matcher("ababa");
  while(matcher.find()){
     System.out.println(matcher.start()+"["+matcher.group()+"]"+matcher.end());
  }
  </code></pre>
  
  <p>Output : </p>
  
  <pre><code>0[a]1
  1[]1
  2[a]3
  3[]3
  4[a]5
  5[]5
  </code></pre>
  
  <p>What I know :</p>
  
  <ul>
  <li>"a?" stands for zero or one occurrence of the character 'a'.</li>
  </ul>
  
  <p>Java API says :  </p>
  
  <ul>
  <li>matcher.start() returns the start index of the previous match.</li>
  <li>matcher.end() returns the offset after the last character matched.</li>
  <li>matcher.group() returns the input subsequence matched by the previous
  match. For a matcher m with input sequence s, the expressions
  m.group() and s.substring(m.start(), m.end()) are equivalent. And for
  some patterns, for example a*, match the empty string. This method
  will return the empty string when the pattern successfully matches
  the empty string in the input.</li>
  </ul>
  
  <p>What I want to know:</p>
  
  <ol>
  <li>In which situations does the regex engine encounters a zero
  occurrence of a given character(s) - Here for character 'a'.</li>
  <li>In those situation what are values actually returns by the start(),
  end() and group() methods in the matcher. I have mentioned what the
  java API said. But I'm little unclear when it comes to the practical
  situation as above.</li>
  </ol>