How do you use lookahead and lookbehind with a short example?

Lookahead, Lookbehind, Perl, Regex
This example illustrates how to use lookahead and lookbehind assertions in Perl regular expressions.
# Example of using lookahead and lookbehind in Perl my $string = "I love Perl programming!"; # Using lookbehind to match 'love' that is preceded by 'I ' if ($string =~ /(?<=I )love/) { print "Matched: 'love' preceded by 'I '\n"; } # Using lookahead to match 'Perl' that is followed by ' programming!' if ($string =~ /Perl(?= programming!)/) { print "Matched: 'Perl' followed by ' programming!'\n"; }

Lookahead Lookbehind Perl Regex