# Use this one if you'd like to account for backslashed quotes my @matches = $string =~ / ((?: (?: ' (?: (?>[^\\']*) | \\ . ) ' ) | \\ . | [^\s'\\]* )+) /gx; # This one does not take backslashed quotes into account #/ #((?: # ' [^']* ' # | [^\s']* #)+) #/gx; # because of the [^\s']*, you'll have matches weaved into your data '' @matches = grep{$_}@matches;