title: Reading and correctly understanding/interpreting control characters from a file (python)
body: <p>I'm a python beginner and just ran into a simple problem: I have a list of names (designators) and then a very simple code that reads lines in a csv file and prints the csv lines that has a name in the first column (row[0]) in common with my "designator list". So:</p>
  
  <pre><code>import csv
  
  DesignatorList = ["AAX-435", "AAX-961", "HHX-9387", "HHX-58", "K-58", "K-14", "K-78524"]
  
  with open('DesignatorFile.csv','rb') as FileReader:
      for row in csv.reader(FileReader, delimiter=';'):
          if row[0] in DesignatorList:
              print row
  </code></pre>
  
  <p>My csv files is only a list of names, like this:</p>
  
  <pre><code>AAX-435
  AAX-961
  HHX-58
  HHX-9387
  </code></pre>
  
  <p>I would like to be able to use wildcards like * and ., example: let's say that I put this on my csv file:</p>
  
  <pre><code>AAX*
  H.X-9387
  *58
  </code></pre>
  
  <p>I need my code to be able to interpret those wild cards/control characters, printing the following:</p>
  
  <ul>
  <li>every line that starts with "AAX";</li>
  <li>every line that starts with "H", then any following character, then finally ends with "X-9387";</li>
  <li>every line that ends with "58".</li>
  </ul>
  
  <p>Thank you!</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> For future reference (in case somebody runs into the same problem), this is how I solved my problem following <a href="https://stackoverflow.com/users/1133649/roman-susi">Roman</a> advice:</p>
  
  <pre><code>import csv
  import re
  DesignatorList = ["AAX-435", "AAX-961", "HHX-9387", "HHX-58", "K-58", "K-14", "K-78524"]
  with open('DesignatorFile.txt','rb') as FileReader:
      for row in csv.reader(FileReader, delimiter=';'):
          designator_col0 = row[0]
          designator_col0_re = re.compile("^" + ".*".join(re.escape(i) for i in designator_col0.split("*")) + "$")
          for d in DesignatorList:
              if designator_col0_re.match(d):
                  print d
  </code></pre>