use strict; use warnings; use Data::Dumper; my $str = q{ABC[GHI]XYZ}; my $rxSplit = qr {(?x) # use extended syntax (?: # non-capturing group \[ # literal opening square br. | # or \] # literal closing square br. | # or (?= # look-ahead, a point # followed by [^]]+ # one or more non-closing # square brs. (?: # non-capturing group # then either \[ # literal opening square br. | # or \z # end of string ) # close non-capturing group ) # close look-ahead ) # close non-capturing group }; my @array = split m{$rxSplit}, $str; print Data::Dumper->Dump([\@array], [qw{*array}]);