Negative/Positive Lookahead/behind
(Positive | Negative) Look(ahead | behind) |
echo "mona lisa" | ag "a"
mona lisa
- -
echo "mona lisa" | ag "a(?= )"
mona lisa
-
echo "mona lisa" | ag "a(?! )"
mona lisa
-
echo "mona lisa" | ag "(?<=n)a"
mona lisa
-
echo "mona lisa" | ag "(?<!n)a"
mona lisa
-
Positive
=
Negative
!
Lookahead
(? )
Lookbehind
(?< )
Positive Lookahead
(?= )
Positive Lookbehind
(?<= )
Negative Lookahead
(?! )
Negative Lookbehind
(?<! )