Regex for strings utility

Nick Efford nde at
Wed Jul 18 12:53:29 CEST 2001

On Tue, 17 Jul 2001 19:07:59 GMT, rhys tucker <rhystucker at> 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 =

might be better.


More information about the Python-list mailing list