in reply to friday morning regex
Note that the whitespace handling in the seperators above is a bit crude, but hey, it's just example code :)use strict; my @subjects=("camel, flea, humbug, hubris", "Camel, Flea, Humbug & Hu +bris","CAMEL, FLEA, HUMBUG and HUBRIS"); for (@subjects) { my @elements=split /\s*,\s*/; push @elements, split /\s+&\s+/, pop(@elements); push @elements, split /\s+and\s+/, pop(@elements); print join "\n", @elements; }
Update: Must have more coffee ... see dingus' post below for a split that does it all in one go. Then again, that brings you right back in regex headache land, so YMMV.
CU
Robartes-
|
|---|