title: Using regular expressions in python raw input
body: <p>I am trying to create a script that will allow a user to enter a number of regular expressions which will pass through an input file and retrieve matches. I am currently using ahocorasick but am getting issues when I try and enter regexed patterns.</p>
  
  <p>I enter a regex into the second raw_input (colour_regex) but receive this error below:</p>
  
  <pre><code>Traceback (most recent call last):
    File "PLA_Enrichment_options.py", line 189, in &lt;module&gt;
      main()
    File "PLA_Enrichment_options.py", line 41, in main
      tree.add(regex)
    File "build/bdist.linux-x86_64/egg/ahocorasick/__init__.py", line 29, in add
  
  TypeError: argument 1 must be string or read-only buffer, not _sre.SRE_Pattern
  
  file_name = raw_input("What is the filename you wish to enhance? ")
  enhanced_name = file_name.replace(".csv", "")
  
  # User regexed input
  tree = ahocorasick.KeywordTree()
  print ("What regex would you like to use for colour? (Enter 'exit' to move on) ")
  colour_regex = raw_input()
  regex = re.compile(colour_regex)
  while colour_regex != "exit":
      tree.add(regex)
  tree.make()
  
  print 'Finding colour matches...'
  output = open(enhanced_name + '-colour.csv', 'w')
  file = open(feed_name, 'r')
  for line in iter(file):
      id, title, desc, link, image = line.strip('\n').split('\t')
      offerString = '|'.join([title.lower(), desc.lower(), link.lower()])
      keywords = set()
      for match in tree.findall_long(offerString): # find colours
          indices = list(match)
          keyword = offerString[indices[0]:indices[1]]
          if re.search(r'(?&lt;![Ã¢ÃªÃ®Ã´Ã»Ã¤Ã«Ã¯Ã¶Ã¼Ã Ã¨Ã¬Ã²Ã¹Ã¡Ã©Ã­Ã³Ãº])\b%s\b(?![Ã¢ÃªÃ®Ã´Ã»Ã¤Ã«Ã¯Ã¶Ã¼Ã Ã¨Ã¬Ã²Ã¹Ã¡Ã©Ã­Ã³Ãº])' %(keyword), offerString):
              keywords.add(keyword)                                     
      if keywords:
          output.write('\t'.join([id, '|'.join(keywords), desc, link, image])+'\n')
      else:
          output.write('\t'.join([id, title, desc, link, image])+'\n')
  file.close()
  output.close()
  </code></pre>
  
  <p>Any help/guidance to the right direction would be great.</p>
  
  <p>Thanks</p>