Extracting text from a string

Paul Rubin http
Thu Sep 7 20:07:00 EDT 2006


"Tim Williams" <tim at tdw.net> writes:
> or even more terse,
> >>> print '\n'.join([i for i in s.splitlines ()[1::2]])

I think it's more robust to use a regexp.

  prices = re.findall('\$\d+\.\d\d', s)
  print '\n'.join(prices)



More information about the Python-list mailing list