title: How to match a text format to a string without regex in python?
body: <p>I am reading a file with lines of the form exemplified by</p>
  
  <pre><code>[ 0 ] L= 9 (D) R= 14 (D) p= 0.0347222 e= 10 n= 34
  </code></pre>
  
  <p>I saw <a href="http://tuvalu.santafe.edu/~aaronc/hierarchy/hrgplot.m" rel="nofollow">Matlab code</a> to read this file given by</p>
  
  <pre><code>[I,L,Ls,R,Rs,p,e,n] = textread(f1,'[ %u ] L= %u%s R= %u%s p= %n e=%u n=%u')
  </code></pre>
  
  <p>I want to read this file in Python. The only thing I know of is regex, and reading even a part of this line leads to something like</p>
  
  <pre><code>re.compile('\s*\[\s*(?P&lt;id&gt;\d+)\s*\]\s*L\s*=\s*(?P&lt;Lint&gt;\d+)\s*\((?P&lt;Ltype&gt;[DG])\)\s*R\s*=\s*(?P&lt;Rint&gt;\d+)\s*')
  </code></pre>
  
  <p>which is ugly! Is there an easier way to do this in Python?</p>