in reply to Re^6: putting text into array word by word
in thread putting text into array word by word
$this_word =~ s/[[:punct:]]//g;
The only problem with that approach is that it removes internal punctuation (ie apostrophes) as well, so that I'll becomes ill, she'd becomes shed, etc. ('Why was Virgina Woolf so obsessed with sheds?' I hear someone ask.)
I'd use this instead:
$this_word =~ s/^[[:punct:]]+//; # Remove leading punct. $this_word =~ s/[[:punct:]]+$//; # Remove trailing punct.
Update: added Virginia Woolf sentence.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^8: putting text into array word by word
by jms53 (Monk) on Jan 10, 2012 at 19:47 UTC | |
by Not_a_Number (Prior) on Jan 10, 2012 at 20:02 UTC | |
by jms53 (Monk) on Jan 10, 2012 at 20:14 UTC |
In Section
Seekers of Perl Wisdom