silent11 has asked for the wisdom of the Perl Monks concerning the following question:
I am in the process of brushing up on my perl basics, reviewing Learning Perl, etc.
I am have a little question dealing with Regex anchoring patterns.
Output:my $string = 'silent eleven'; if ($string =~ /\b \b/){ print "yes to 1\n"; } if ($string =~ /\b \b$/){ print "yes to 2\n"; } if ($string =~ /\b$/){ print "yes to 3\n"; }
Why is the second if statement not returning true? Can these 2 "anchors" not be next to each other? Perhaps I am missing the point of using anchors. Any help or explanation would be appreciated.Z:\>perl anchor.pl yes to 1 yes to 3
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex Anchors confusion
by merlyn (Sage) on May 18, 2005 at 14:21 UTC | |
Re: Regex Anchors confusion
by inman (Curate) on May 18, 2005 at 14:23 UTC | |
by japhy (Canon) on May 18, 2005 at 15:14 UTC | |
by merlyn (Sage) on May 18, 2005 at 15:30 UTC | |
by japhy (Canon) on May 18, 2005 at 16:02 UTC | |
Re: Regex Anchors confusion
by mrborisguy (Hermit) on May 18, 2005 at 14:19 UTC | |
by kelan (Deacon) on May 18, 2005 at 14:53 UTC |
Back to
Seekers of Perl Wisdom