my $str = qq|"this is one" and "anot""her one" is "" right "her"e|; my @stuff = map { /([^"]+)"$/ } $str =~ /"([^"]*"|[^\s"]+)/g; print join("\n", @stuff), "\n";