in reply to Re: Re: Why do zero width assertions care about lookahead/behind?
in thread Why do zero width assertions care about lookahead/behind?
/(?=abc)\b/ matches at a word boundary that is followed by "abc", hence after "---", but before "abc". /(?<=abc)\b/ matches at a word boundary that is preceded by "abc", hence after "abc", and right before the end of the string.#!/usr/bin/perl use strict; use warnings; $_ = "---abc"; /(?=abc)\b/ and print "Lookahead \$` = '$`'; \$' = '$''\n"; /(?<=abc)\b/ and print "Lookbehind \$` = '$`'; \$' = '$''\n"; __END__ Lookahead $` = '---'; $' = 'abc' Lookbehind $` = '---abc'; $' = ''
Abigail
|
|---|