Why does a simple .*? non-greedy regex greedily include additional characters before a match?

I figured out a solution with some help from Regex lazy vs greedy confusion. In regex engines like the one used by Javascript (NFA engines I believe), non-greedy only gives you the match that is shortest going left to right – from the first left-hand match that fits to the nearest right-hand match. Where there … Read more

What do ‘lazy’ and ‘greedy’ mean in the context of regular expressions?

Greedy will consume as much as possible. From http://www.regular-expressions.info/repeat.html we see the example of trying to match HTML tags with <.+>. Suppose you have the following: <em>Hello World</em> You may think that <.+> (. means any non newline character and + means one or more) would only match the <em> and the </em>, when in … Read more

tech