How can I write a regex which matches non greedy? [duplicate]

This question already has answers here: What do ‘lazy’ and ‘greedy’ mean in the context of regular expressions? (12 answers) How do I match any character across multiple lines in a regular expression? (25 answers) What is the difference between .*? and .* regular expressions? (3 answers) RegEx: Smallest possible match or nongreedy match (3 … Read more

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

What are these two terms in an understandable way? 12 s 12 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 … Read more