newbio has asked for the wisdom of the Perl Monks concerning the following question:
I want to include a space charcter in the map function below, so that each phrase pattern to be matched in the sentence also includes space characters on its either side. However, it does not work in the form below (although \b in place of \s works but it does not solve the actual problem). Any suggestions?
my $string = join '|', map { "\\s$_\\s" } map { quotemeta } @phrases; $sentence =~ s/($string)/\#$1\#/g;
Thanks.
#Corrected: $phrases replaced by $string
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: map function use
by ikegami (Patriarch) on Aug 13, 2009 at 19:01 UTC | |
|
Re: map function use
by moritz (Cardinal) on Aug 13, 2009 at 18:50 UTC | |
by newbio (Beadle) on Aug 13, 2009 at 19:21 UTC | |
by ig (Vicar) on Aug 13, 2009 at 19:49 UTC | |
by ikegami (Patriarch) on Aug 13, 2009 at 22:29 UTC | |
|
Re: map function use
by jwkrahn (Abbot) on Aug 13, 2009 at 19:01 UTC | |
|
Re: map function use
by ig (Vicar) on Aug 13, 2009 at 19:31 UTC | |
|
Re: map function use
by JavaFan (Canon) on Aug 13, 2009 at 19:03 UTC | |
by AnomalousMonk (Archbishop) on Aug 14, 2009 at 05:52 UTC |