GuiPerl has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; while (<DATA>) { if ($_ =~ m/\bGuinea\b/) { print "We have a match\n"; # m/\bGuinea\b$/ matches Guinea at end #m/^\bGuinea\b$/ matches Guinea at the beginning } else { print "We do not have a match\n"; } } __DATA__ Papua New Guinea I live in Guinea Guinea Bissau Equatorial Guinea
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching a Word Exactly
by karlgoethebier (Abbot) on Oct 09, 2014 at 11:30 UTC | |
|
Re: Matching Exact Word
by Anonymous Monk on Oct 09, 2014 at 09:16 UTC | |
by Anonymous Monk on Oct 09, 2014 at 09:20 UTC | |
by jonadab (Parson) on Oct 09, 2014 at 11:01 UTC | |
by Jim (Curate) on Oct 09, 2014 at 18:33 UTC | |
by kzwix (Sexton) on Oct 09, 2014 at 11:20 UTC |