Greedy And Non Greedy Pattern Matching In Python