Greedy will consume as much as possible.
So for example <.+>
will match whole <EM>first</EM>
However <.+?>
will match only <EM>
as it is lazy matching.
Now you must understand that /g
modifier can be used with both greedy matching and lazy matching.
For example,
<EM>first</EM>
and you use <.+>/g
it will replace full expression with specified one.
However <.+?>/g
will replace <EM>
and </EM>
only with specified expression.