<div>Hello,</div>
<div> </div>
<div>I am trying to write a script that takes strings from a text file and searches to see if they are present in another text file...here is the code:</div>
<div> </div>
<div>import os<br>import re</div>
<div>
<p>search = open("c:\python24\scripts\pii\expected_rules_results.txt")</p>
<p>def find(x):<br> file = open("c:\python24\scripts\pii\dave.txt")<br> regexp = re.compile(x)<br> for line in file.readlines():<br> if regexp.search(line):<br> print "Found", x<br> break<br> <br>
<br> file.close() <br> </p>
<p>for x in search:<br> find(x)<br>search.close()</p>
<p> </p>
<p>Unfortunately the strings I will be searching for contain numerous "*" that cause an error. For example, when try to search for:</p>
<p><a href="http://www.widget.com/personal_firewall.csp/?pin=****{6">http://www.widget.com/personal_firewall.csp/?pin=****{6</a>}</p>
<p>I get the error message:</p>
<p>Traceback (most recent call last):<br> File "C:\Python24\scripts\PII\search<br> find(x)<br> File "C:\Python24\scripts\PII\search<br> regexp = re.compile(x)<br> File "C:\Python24\lib\sre.py", line
<br> return _compile(pattern, flags)<br> File "C:\Python24\lib\sre.py", line<br> raise error, v # invalid expressio<br>sre_constants.error: multiple repeat</p>
<p> </p>
<p>Anyone know how to get around this?</p></div>