$field = "Search, This is part of the code.";
## We need to split by spaces. The issue is that the comma comes along.
local(@words) = split('\s+', $field);
foreach $word (@words) {
if ($word =~ /Search/i) {
$word =~ s/[,\]\)\}]\b//;
$word =~ s/\b[,\]\)\}]//;
push(@new_array, $word);
last;
}
}
This code removes the comma. But I am puzzeled. I thought that the first line
$word =~ s/[,\]\)\}]\b//;
would delete the comma.
Yet it was the second line that did it.
$word =~ s/\b[,\]\)\}]//;
The comma is at the end of the word, before the boundary. Shouldn't the first
line have gottne rid of it.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>