Using Perl, I would like to split a string on the comma and the “and” (that may or may not be preceded by a comma.
"Apple"gives array(Apple)"Apple and Orange"gives array(Apple Orange)"Apple, Orange, and Banana"gives array(Apple Orange Banana)
For some reason the following split regex is not working for me:
split(/(,| and )/, $string)
Try this:
Example:
Or a simpler working case for your example: