diff --git a/Akash Articles/RegEx/lazy_matching.html b/Akash Articles/RegEx/lazy_matching.html new file mode 100644 index 0000000..5e6b051 --- /dev/null +++ b/Akash Articles/RegEx/lazy_matching.html @@ -0,0 +1,99 @@ + +
+ + + + + + + + + + + +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.
+ + + + + +