Can I beat perl at grep-like processing speed?

Fredrik Lundh fredrik at pythonware.com
Wed Jan 3 10:30:41 EST 2007


Nick Craig-Wood wrote:

>>  #!/usr/bin/env python
>>  import re
>>  r = re.compile(r'destroy', re.IGNORECASE)
>>
>>  for s in file('bigfile'):
>>    if r.search(s): print s.rstrip("\r\n")

footnote: if you're searching for literal strings with Python 2.5, using "in" is a
lot faster than using re.search.

</F> 






More information about the Python-list mailing list