title: Matching with regex line for line
body: <p>I am working on a fun little language using regex matching lines in a file. Here is what I have so far:</p>
  
  <pre><code>import re
  
  code=open("code.txt", "r").read()
  
  outputf=r'output (.*)'
  inputf=r'(.*) = input (.*)'
  intf=r'int (.*) = (\d)'
  floatf=r'float (.*) = (\d\.\d)'
  outputq=re.match(outputf, code)
  if outputq:
      print "Executing OUTPUT query"
      exec "print %s" %outputq.group(1)
  
  inputq=re.match(inputf, code)
  if inputq:
      print "Executing INPUT query"
      exec "%s=raw_input(%s)"%(inputq.group(1), inputq.group(2))
  
  intq=re.match(intf, code)
  if intq:
      exec "%s = %s"%(intq.group(1), intq.group(2))
      exec "print %s"%(intq.group(1))
  else:
      print "Invalid syntax"
  </code></pre>
  
  <p>The code works in matching say:</p>
  
  <pre><code>int x = 1
  </code></pre>
  
  <p>But it will only match the first line and stop matching and ignore the rest of the code that I want to match. How can I match every line in the file to my regex definitions?</p>