I am teaching myself regular expressions, and I got stuck at »greedy« vs. »lazy« repeatings.
What I found out so far is that
- »greedy« means that the RegExp looks for as many matches as possible, where
- »lazy« means that the RegExp looks for as little matches as possible
Most articles I found deal with a) using it in a programming language, while I am stuck here with
egrep or b) use
grep -P to activate
Perl Mode; but as I don't have any knowledge about Perl yet this isn't very helpful for me.
My comprehension question: I came to this sledgehammer method:
- lazy repetitions will look for the shortest possible match
- if results are too long → tone down the repeater with
- if results are still too long → look for another solution
This is what I was able to figure out through examples and experiments with HTML code where I got to some but not overwhelming results.
I would be grateful if somebody could tell me if and where I missed some important points with my summary.