WOW, i'm sure i've never tried .*? in a regex, so if that was supposed to make sense, ignore me
This example should clearly illustrate the difference.
$_ = '<S>abc<E> <S>def<E>'; print("Greedy:\n"); print(" $1\n") while /<S>(.*)<E>/g; print("Non-greedy:\n"); print(" $1\n") while /<S>(.*?)<E>/g;
Greedy: abc<E> <S>def Non-greedy: abc def
In reply to Re^2: regex help humbly sought
by ikegami
in thread regex help humbly sought
by charlie_pi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |