excluding search string in regular expressions
Franz Steinhaeusler
franz.steinhaeusler at utanet.at
Fri Oct 22 04:54:36 EDT 2004
On Thu, 21 Oct 2004 22:38:00 GMT, bokr at oz.net (Bengt Richter) wrote:
>
>To look back a line, I think I'd just use a generator, and test current
>and last lines to get what I wanted. E.g., perhaps you can adapt this:
>(I am just going literally by
> """
> find only occurances, where in the line are'::' characters and
> the former line is not equal '**/'
> """
>which doesn't need a regex)
>
> >>> def findem(lineseq):
> ... getline = iter(lineseq).next
> ... curr = getline().rstrip()
> ... while True:
> ... last, curr = curr, getline().rstrip()
> ... if '::' in curr and last != '**/': yield curr
> ...
>[...]
>
>Regards,
>Bengt Richter
Hello Bengt,
thank you for suggesting this interesting approach,
regards
--
Franz Steinhaeusler
More information about the Python-list
mailing list