@@ -405,13 +405,13 @@ that is matched by the first part of the expression. To define a positive
405
405
lookahead, parentheses are used. Within those parentheses, a question mark with
406
406
equal sign is used like this: ` (?=...) ` . Lookahead expression is written after
407
407
the equal sign inside parentheses. For example, the regular expression
408
- ` [ T|t] he(?=\sfat)` means: optionally match lowercase letter ` t ` or uppercase
408
+ ` ( T|t) he(?=\sfat)` means: optionally match lowercase letter ` t ` or uppercase
409
409
letter ` T ` , followed by letter ` h ` , followed by letter ` e ` . In parentheses we
410
410
define positive lookahead which tells regular expression engine to match ` The `
411
411
or ` the ` which are followed by the word ` fat ` .
412
412
413
413
<pre >
414
- "[ T|t] he(?=\sfat)" => <a href =" #learn-regex " ><strong >The</strong ></a > fat cat sat on the mat.
414
+ "( T|t) he(?=\sfat)" => <a href =" #learn-regex " ><strong >The</strong ></a > fat cat sat on the mat.
415
415
</pre >
416
416
417
417
[ Test the regular expression] ( https://regex101.com/r/IDDARt/1 )
@@ -422,12 +422,12 @@ Negative lookahead is used when we need to get all matches from input string
422
422
that are not followed by a pattern. Negative lookahead defined same as we define
423
423
positive lookahead but the only difference is instead of equal ` = ` character we
424
424
use negation ` ! ` character i.e. ` (?!...) ` . Let's take a look at the following
425
- regular expression ` [ T|t] he(?!\sfat)` which means: get all ` The ` or ` the ` words
425
+ regular expression ` ( T|t) he(?!\sfat)` which means: get all ` The ` or ` the ` words
426
426
from input string that are not followed by the word ` fat ` precedes by a space
427
427
character.
428
428
429
429
<pre >
430
- "[ T|t] he(?!\sfat)" => The fat cat sat on <a href =" #learn-regex " ><strong >the</strong ></a > mat.
430
+ "( T|t) he(?!\sfat)" => The fat cat sat on <a href =" #learn-regex " ><strong >the</strong ></a > mat.
431
431
</pre >
432
432
433
433
[ Test the regular expression] ( https://regex101.com/r/V32Npg/1 )
@@ -436,11 +436,11 @@ character.
436
436
437
437
Positive lookbehind is used to get all the matches that are preceded by a
438
438
specific pattern. Positive lookbehind is denoted by ` (?<=...) ` . For example, the
439
- regular expression ` (?<=[ T|t] he\s)(fat|mat) ` means: get all ` fat ` or ` mat ` words
439
+ regular expression ` (?<=( T|t) he\s)(fat|mat) ` means: get all ` fat ` or ` mat ` words
440
440
from input string that are after the word ` The ` or ` the ` .
441
441
442
442
<pre >
443
- "(?<=[ T|t] he\s)(fat|mat)" => The <a href =" #learn-regex " ><strong >fat</strong ></a > cat sat on the <a href =" #learn-regex " ><strong >mat</strong ></a >.
443
+ "(?<=( T|t) he\s)(fat|mat)" => The <a href =" #learn-regex " ><strong >fat</strong ></a > cat sat on the <a href =" #learn-regex " ><strong >mat</strong ></a >.
444
444
</pre >
445
445
446
446
[ Test the regular expression] ( https://regex101.com/r/avH165/1 )
@@ -453,7 +453,7 @@ regular expression `(?<!(T|t)he\s)(cat)` means: get all `cat` words from input
453
453
string that are not after the word ` The ` or ` the ` .
454
454
455
455
<pre >
456
- "(?< ; ![ T|t] he\s)(cat)" => The cat sat on <a href =" #learn-regex " ><strong >cat</strong ></a >.
456
+ "(?< ; !( T|t) he\s)(cat)" => The cat sat on <a href =" #learn-regex " ><strong >cat</strong ></a >.
457
457
</pre >
458
458
459
459
[ Test the regular expression] ( https://regex101.com/r/8Efx5G/1 )
0 commit comments