Oops, made a mistake.

Marc Huffnagle wrote:
Dasacc

There is a better (faster/easier) way to do it than using the re module, the find method of the string class.

[EMAIL PROTECTED] wrote:

(1) How do I perform a search for "word" and have it return every line
that this instance is found?


[line for line in document if line.find('a') != -1]


(2) How do I perform a search for "word" and "wordtwo" at the same time to return every line these instances are found so that the order in which these lines are in are left intact.


[line for line in document if (line.find('word') != -1 \
    and line.find('wordtwo'))]

This should have been:

[line for line in document if (line.find('word') != -1 \
        and line.find('wordtwo') != -1)]



If there's another standard module more suited for this let me know, and no I dont want to use sed :)

Thanks

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to