Stevee <> wrote in comp.lang.perl.misc:
> Hi all.
>
> Apologies if this is a newbie question, but I am new!
>
> I am reading in a string, splitting it into chunks on whitespace and
> placing the values in an array which I then process further to match.
> I am having problems because some of the matches are not working
> because the chunking gives things like
>
> "martin, "
>
> or
>
> "martin. "
No, it doesn't, not if you split on white space. Your examples
*contain* white space. Show your code so it is clear what you
are doing.
> i.e there is a comma or full stop as the end of the chunk.
>
> Any ideas how to remove the punctuation before I put the values in the
> array to match?
You could split on a combination of white space and punctuation:
my $sentence = "Martin, Martin. O'Brien!";
print "$_\n" for split /[[:space:][

unct:]]+/, $sentence;
....or maybe not. You need to define what is punctuation and what
isn't.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.