En Mon, 30 Apr 2007 19:16:58 -0300, John Davis <[EMAIL PROTECTED]>
escribió:
> Hi all,
> I have a large logged string "str". I would like to strip down "str" so
> that
> it contains only the lines that have "ERROR" in them. Could somebody
> give me
> and indication of how to do this?
Forget about regular expressions! This famous quote [1] is entirely
applicable here.
Also, str is not a good name, it hides the builtin type str. Using text as
the variable name instead:
error_lines = [line for line in text.split("\n") if "ERROR" in line]
[1] http://regex.info/blog/2006-09-15/247
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list