Regex for strings utility
rhys tucker
rhystucker at yahoo.com
Tue Jul 17 15:07:59 EDT 2001
I'm trying to write a script which operates like the Unix 'strings' utility but I'm having difficulties with the regex.
#!/usr/bin/env python
# strings program
import sys, re
f = open(sys.argv[1])
line = f.readline()
pattern = ([\040-\126\s]{4,})
while line:
# regular expression to match strings >=4 chars goes here
matches = findall(pattern, line)
for match in matches;
print match
line = f.readline()
I'm getting a Syntax Error: Invalid Token at the closing brace to the pattern.
thanks,
rhys
More information about the Python-list
mailing list