Extracting text from a string

Paul Rubin http
Fri Sep 8 02:07:00 CEST 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