仮定:
my $s1='A "sentence" ... is a concatination of nondelimiters followed by delimiters,
followed by nondelimiters, followed by delimiters, ...';
また
my $s2='"A "sentence" ... is a concatination of delimiters followed by nondelimiters,
followed by delimiters, followed by nondelimiters, ..."';
スカラー$dに設定された区切り文字を使用して、正規表現でリスト@aに分割しようとしています。
my $d = ' ,."'; # delimiter set
my @a = $s1 =~ /([^$d]+)([$d]+)/g; # gives |A| "|sentence|" ... |is| |a| |...
2番目のケースでは、上の文は
my @a = $s2 =~ /([$d]+)([^$d]+)/g; # gives |"|A| "|sentence|" ... |is| |a|...
単一の正規表現で両方のケースをどのように処理できますか?助けが必要です-お願いします。