Sure, if you can exactly tell what the regex should accomplish -
- split commas
-
except commas between quotes
-
except it's not between any quotes, but the quotes must be balanced
-
perhaps the quotes are nested
-
escaped quotes (\') have to be exempt
-
the same conditions for double quotes
-
them mixed and matched
-
what about escaped commas (\,)?
-
other special cases I forgot to think of?
I
do use
split sometimes, but only if it's guaranteed to be commas only. As soon as a special case becomes visible on the horizon, I use
Text::CSV (which in turn uses
Text::CSV_XS if possible).