mirror of
https://github.com/ziishaned/learn-regex.git
synced 2025-08-05 11:06:46 -04:00
commit
d1ae5ee5e4
@ -422,7 +422,7 @@ shorthand character sets are as follows:
|
|||||||
## 4. Lookaround
|
## 4. Lookaround
|
||||||
|
|
||||||
Lookbehind and lookahead (also called lookaround) are specific types of
|
Lookbehind and lookahead (also called lookaround) are specific types of
|
||||||
***non-capturing groups*** (Used to match the pattern but not included in matching
|
***non-capturing groups*** (used to match the pattern but not included in matching
|
||||||
list). Lookarounds are used when we have the condition that this pattern is
|
list). Lookarounds are used when we have the condition that this pattern is
|
||||||
preceded or followed by another certain pattern. For example, we want to get all
|
preceded or followed by another certain pattern. For example, we want to get all
|
||||||
numbers that are preceded by `$` character from the following input string
|
numbers that are preceded by `$` character from the following input string
|
||||||
@ -579,8 +579,8 @@ at the end of each line in a string.
|
|||||||
[Test the regular expression](https://regex101.com/r/E88WE2/1)
|
[Test the regular expression](https://regex101.com/r/E88WE2/1)
|
||||||
|
|
||||||
## 6. Greedy vs lazy matching
|
## 6. Greedy vs lazy matching
|
||||||
By default regex will do greedy matching , means it will match as long as
|
By default regex will do greedy matching which means it will match as long as
|
||||||
possible. we can use `?` to match in lazy way means as short as possible
|
possible. We can use `?` to match in lazy way which means as short as possible.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
"/(.*at)/" => <a href="#learn-regex"><strong>The fat cat sat on the mat</strong></a>. </pre>
|
"/(.*at)/" => <a href="#learn-regex"><strong>The fat cat sat on the mat</strong></a>. </pre>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user