in reply to regular expression and nested tags
It just means that when it's time to do matching of the non-greedy subpattern, of all the possible submatches that start of the current point that will lead to an overall match, it'll pick the shortest submatch.
So, the <div will match the first div, then after the matching for the first div Perl finds the smallest submatch that makes the entire pattern match.
Hence the result you're getting.
If you want to match <div> and </div> with no <div> in between, write your pattern accordingly. Or just use one of the many HTML parsing modules out there.
|
|---|