shortest match regexp operator anyone?

Fredrik Lundh fredrik at
Wed Jul 11 16:17:58 EDT 2001

Harald Kirsch wrote:
> 2) TASK: Find the first '<A>' and match, if it is followed by a 'B'
>    SOLUTION: ???
> An approximation for (2) is '^[^<>A]+<A>B', but it does not match
> 'A<A>B', which it should.
> With non-greedy matching, another approximation is '^.*?<A>B', however
> this matches 'xx<A>y<A>B', although it should not.



More information about the Python-list mailing list