Regex for strings utility
Nick Efford
nde at comp.leeds.ac.uk
Wed Jul 18 06:53:29 EDT 2001
On Tue, 17 Jul 2001 19:07:59 GMT, rhys tucker <rhystucker at yahoo.com> wrote:
> 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()
This isn't answering your regex question but...
You're opening a text file and reading it line-by-line
here, which probably isn't what you want if you are
trying to duplicate the behaviour of 'strings' exactly.
f = open(sys.argv[1], 'rb')
data = f.read()
might be better.
Nick
More information about the Python-list
mailing list