Jayakumar Rajagopal wrote:
> friends,
>
> script :
>
> $_='as great as perl';
> print $& ."\n" if (/\beat/);
> print $& ."\n" if (/\bgre/);
>
> output :
> gre
> ***
> Why 'boundary' assertion does not match in end of word , but only the
> start of wor
If I'm reading this correctly, you are trying to match a word at the end of a string.
If that's the case then move the word boundary to the end of your match.
print $& ."\n" if (/eat\b/);
print $& ."\n" if (/gre\b/);
Reading from the "Learning Perl 3rd" Edition on page 108:
"The \b anchor matc
friends,
script :
$_='as great as perl';
print $& ."\n" if (/\beat/);
print $& ."\n" if (/\bgre/);
output :
gre
***
Why 'boundary' assertion does not match in end of word , but only the start of word?
thanks,
Jay
--
To unsubscribe, e-mail: [EMAIL PRO