Lazy matching:

As we have seen, the default nature of quantifiers is greedy, so it will match as many characters as possible.

To make it lazy, we use ? quantifier, which turns the regex engine to match as less characters as possible which satisfies the regex.

So, now we can match html tags as below:

Let's have one more example,

Problem

Find an expression to match href="url" in html file. Note that url can be anything, like https://xyz.com, http://abc.io/app, https://cde.org.

Answer: href=".*?"

We will see how to extract things(like, urls) from the text using regex, in the "group and capturing" concept.