mirror of
https://github.com/ziishaned/learn-regex.git
synced 2025-09-22 11:23:30 -04:00
#103 add greedy vs lazy matching
This commit is contained in:
parent
f160d21c0c
commit
3949d99e4d
17
README.md
17
README.md
@ -539,6 +539,23 @@ at the end of each line in a string.
|
||||
|
||||
[Test the regular expression](https://regex101.com/r/E88WE2/1)
|
||||
|
||||
## 6. Greedy vs lazy matching
|
||||
By default regex will do greedy matching , means it will match as long as
|
||||
possible. we can use `?` to match in lazy way means as short as possible
|
||||
|
||||
<pre>
|
||||
"/(.*at)/" => <a href="#learn-regex"><strong>The fat cat sat on the mat.</strong></a> </pre>
|
||||
|
||||
|
||||
[Test the regular expression](https://regex101.com/r/AyAdgJ/1)
|
||||
|
||||
<pre>
|
||||
"/(.*?at)/" => <a href="#learn-regex"><strong>The fat</strong></a> cat sat on the mat. </pre>
|
||||
|
||||
|
||||
[Test the regular expression](https://regex101.com/r/AyAdgJ/2)
|
||||
|
||||
|
||||
## Contribution
|
||||
|
||||
* Report issues
|
||||
|
Loading…
x
Reference in New Issue
Block a user