title: ply lexmatch regular expression has different groups than a usual re
body: <p>I am using ply and have noticed a strange discrepancy between the token re match stored in t.lex.lexmatch, as compared with an sre_pattern defined in the usual way with the re module.  The group(x)'s seem to be off by 1.</p>
  
  <p>I have defined a simple lexer to illustrate the behavior I am seeing:</p>
  
  <pre><code>import ply.lex as lex
  
  tokens = ('CHAR',)
  
  def t_CHAR(t):
      r'.'
      t.value = t.lexer.lexmatch
      return t
  
  l = lex.lex()
  </code></pre>
  
  <p>(I get a warning about t_error but ignore it for now.)  Now I feed some input into the lexer and get a token:</p>
  
  <pre><code>l.input('hello')
  l.token()
  </code></pre>
  
  <p>I get a <code>LexToken(CHAR,&lt;_sre.SRE_Match object at 0x100fb1eb8&gt;,1,0)</code>.  I want to look a the match object:</p>
  
  <pre><code>m = _.value
  </code></pre>
  
  <p>So now I look at the groups:</p>
  
  <p><code>m.group()</code> => <code>'h'</code> as I expect.</p>
  
  <p><code>m.group(0)</code> => <code>'h'</code> as I expect.</p>
  
  <p><code>m.group(1)</code> => <code>'h'</code>, yet I would expect it to not have such a group.</p>
  
  <p>Compare this to creating such a regular expression manually:</p>
  
  <pre><code>import re
  p = re.compile(r'.')
  m2 = p.match('hello')
  </code></pre>
  
  <p>This gives different groups:</p>
  
  <p><code>m2.group()</code> = <code>'h'</code> as I expect.</p>
  
  <p><code>m2.group(0)</code> = <code>'h'</code> as I expect.</p>
  
  <p><code>m2.group(1)</code> gives <code>IndexError: no such group</code> as I expect.</p>
  
  <p>Does anyone know why this discrepancy exists?</p>