On 19 Gru, 13:08, Sharun <[EMAIL PROTECTED]> wrote:
> I am trying to find the substring starting with 'aaa', and ending with
> ddd OR fff. If ddd is found shouldnt the search stop? Shouldn't
> re5.search(str5).group(0) return 'aaa bbb\r\n ccc ddd' ?

The documentation for the re module (http://docs.python.org/lib/re-
syntax.html), tells you that the "*", "+", and "?" qualifiers are all
greedy; they match as much text as possible. What you are looking for
are the qualifiers "*?", "+?", "??". Your regex pattern might look
like this: "aaa.*?(ddd|fff)".

Regards,
Marek
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to