Hi Perl monks,
I have a problem involving the split function applied to a text containing many different Unicode variations of A, B, C...Z. I want to get the list of words of any text I feed it, including the ones that have "®" or "™" attached to a word. Unfortunately, the regex I got so far also attaches "…" or "†" (dagger) to the words, so that I get "Canal†", "old..." and “ kraal¹ “ instead of simply "Canal", "old" and “kraal”.
Here's the script:
#!/usr/bin/perl
usewarnings;
$textBlock="Belgium is a monarchy. Ionuț, close the door. The bui
+ldings in Japan.
This is a sky-blue* \"material\". Here's the list:
The Eire Canal† is old…
Is Apple™ only a computer company?
www.fjydhjfjxerhuir.com is the site — go there. old-man-of-the-woods
(forget-me-not) [digital] bogus_address99@geemail.com
She's there. replace «date»
They live in a kraal¹. façade
Mac OS X® is slated to ship in May. Überzone șăâțî
http://language.perl.com/faq";
@wordList=split/[^-A-Z®À-ÖØ-öù-žǍ-ȚḀ-ẛẠ-&#
+7929;™]+/i, $textBlock;
foreach (@wordList) {
print "$_\n";
}
As you can see, I try to determine the delimiters needed for the split to be anything else except the characters included in this interval --> "-A-Z®À-ÖØ-öù-žǍ-ȚḀ-ẛẠ-ỹ™", but I still get unwanted punctuation characters added to words... There's no overlaping between these characters (i.e., they are in the proper order, with "-" first at 0045 and "™" (the trademark symbol) last at 8482, if i remember correctly :^)
So... what am I doing wrong? Please enlighten me...
(I have Perl 5.8.8 on Mac OS X, if that matters)