use strict;
my $str = ' そこは純白の空間だった。
四方の壁は継ぎ目の無い白塗り、中央に鎮座する祭壇も雪を固めたように真っ白で、この部屋を満たす光もまた白く輝いていた。
「供物を捧げよ」
どこからとも無く部屋中に響き渡る声。
開け放たれた両開きの扉、その暗い通路の向こうから人の列がやってくる。白い部屋と同じように、その人々もまた白尽くめであった。
染み一つ無い清潔な白いローブで全身を覆い、顔には白いマスクを被り、素肌を露出している部分が一切無い。';
my $regex = qr/.{1,}?([。.」??!!]+|\n)/miup;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html