title: Python Regular Expression loop
body: <p>I have this code wich will look for certain things in a file. The file looks like this:</p>
  
  <pre><code>name;lastname;job;5465465
  name2;lastname2;job2;5465465
  name3;lastname3;job3;5465465
  </code></pre>
  
  <p>This is the python code:</p>
  
  <pre><code>import re
  import sys
  
  filehandle = open('somefile.csv', 'r')
  text = filehandle.read()
  b = re.search("([a-zA-Z]+);([a-z\sA-Z]+);([a-zA-Z]*);([0-9^-]+)\n?",text)
  print (b.group(2),b.group(1),b.group(3),b.group(4))
  </code></pre>
  
  <p>no it will only print:</p>
  
  <pre><code>lastname;name;job;5465465
  </code></pre>
  
  <p>It supposed to print the lastname first so i did that with groups. Now i need a loop to print all lines like this:</p>
  
  <pre><code>lastname;name;job;5465465
  lastname2;name2;job2;5465465
  lastname3;name3;job3;5465465l
  </code></pre>
  
  <p>i tried all kind of loops but it doesnt go trough the whole file... how do i need to do this?</p>
  
  <p>it must be done with the re module. I know its easy in the csv module ;)</p>