title: Regular expression (re.search) is unable to detect errors
body: <p>I am trying to detect errors in data in a CSV file using <code>re.search</code> in which incorrect data (that does not match the given pattern) will be sent to one list (error), while the correct data (that does match the pattern) will be sent to another list (clean).</p>
  <p>This is how the data looks in the CSV file:</p>
  <pre class="lang-none prettyprint-override"><code>UES9151GS5  DEN PEK
  UES915*GS5  JFK FCO
  WYu2010YH8  ORD CAN
  HCA3158QA6  ORD ~AN
  HCA3158QA6  KUL A;S
  HCA3158QA6  0   LHR
  HCA3158QA6  A;S ORD
  HCA3158QA6  ~AN PVG
  </code></pre>
  <p>and this is my code:</p>
  <pre class="lang-py prettyprint-override"><code>import csv
  import re
  
  clean = []
  error = []
  
  pid_pattern = '[A-Z]{3}[0-9]{4}[A-Z]{2}[0-9]'
  dept_pattern = '[A-Z]{3}'
  arr_pattern = '[A-Z]{3}'
  
  with open(r&quot;test.csv&quot;) as csvfile:
      reader = csvfile
      for i in reader:
          pid = re.search(pid_pattern, i)
          dept = re.search(dept_pattern, i)
          arr = re.search(arr_pattern, i)
          
          if pid !=None and dept != None and arr != None:
               clean.append(i)
          elif pid == None:
              error.append(i)
          elif dept == None:
              error.append(i)
          elif arr == None:
              error.append(i)
  </code></pre>
  <p>So, after I run the code I get:</p>
  <pre class="lang-py prettyprint-override"><code>clean
  ['UES9151GS5,DEN,PEK\n',
   'HCA3158QA6,ORD,~AN\n',
   'HCA3158QA6,A;S,A;S,\n',
   'HCA3158QA6,0,LHR\n',
   'HCA3158QA6,A;S,ORD\n',
   'HCA3158QA6,~AN,PVG\n']
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>error
  ['UES915*GS5,JFK,FCO\n',
   'WYu2010YH8,ORD,CAN\n']
  </code></pre>
  <p>Apparently the code only checks the first column (pid) and ignores the rest. The expected result should be like this:</p>
  <pre class="lang-py prettyprint-override"><code>clean
  ['UES9151GS5,DEN,PEK\n']
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>error
  ['HCA3158QA6,ORD,~AN\n',
   'HCA3158QA6,A;S,A;S,\n',
   'HCA3158QA6,0,LHR\n',
   'HCA3158QA6,A;S,ORD\n',
   'HCA3158QA6,~AN,PVG\n',
   'UES915*GS5,JFK,FCO\n',
   'WYu2010YH8,ORD,CAN\n']
  </code></pre>
  <p>Up until now I am unable to locate the error or find any alternative solution.</p>