+ 1
What is the difference between greedy and non-greedy matching in Regular expression?
Regular expression
2 Réponses
0
Greedy mode tries to match the longest possible term first and non-greedy tries to match the shortest possible term first.
0
lets take following example : Mool Chand is a good human being. Mool Chand always pays tax. Mool Chand is learning Python.
non greedy : ".*?" for ex : Mool Chand.*? Mool Chand only pass string up to starting of second statement. Where as greedy : ".*" Mool Chand .* Mool Chand pass string up to thrid statement.