in reply to split string using regex

my $inp = 'AAA * BBB CCC * * "2000 01 00 00 00" "2004 01 00 00 00"' ; my @r; while ($inp =~ /( [^"\s]+ | "[^"]+?" ) /gx) { my $a = $1; $a =~ s/(?:^"|"$)//g; push @r, $a; } print join "\n", @r, '';
Do you really not want to match AAA? I assumed you want AAA in there; if not, shift @r or something. This solution isn't the most efficient, but I think it's clear enough to expand upon (or abandon in favor of Text::CSV_XS).