Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
the if-statement is true if $check="foo-bar doo" and it's also true if $check="bar doo" I need it to match 'foo-bar doo' only, not 'bar doo'. Is there a possibility to include '-' into /b? Or should I do it another way? Thanks in advance! Lynn$string_to_check="yyy foo-bar doo zzz"; if ($string_to_check =~ /\b$check\b/) { ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Word boundary in regexp
by ikegami (Patriarch) on Jan 25, 2012 at 21:48 UTC | |
|
Re: Word boundary in regexp
by Eliya (Vicar) on Jan 25, 2012 at 21:30 UTC | |
|
Re: Word boundary in regexp
by JavaFan (Canon) on Jan 25, 2012 at 21:16 UTC | |
|
Re: Word boundary in regexp
by JavaFan (Canon) on Jan 25, 2012 at 21:04 UTC | |
|
Re: Word boundary in regexp
by Anonymous Monk on Jan 25, 2012 at 22:27 UTC |