use Test::More tests => 5; my $string = '(1,"(text),(text)", 123),(2,"(string)", 234),(...)'; my @parts = split m{ [)] [,] [(] }x, $string; # Prove that the split worked properly... # Firstly, joining the parts back with '),(' recreates the original string. my $joined = join '),(', @parts; is($joined, $string); # Secondly, none of the individual parts contain '),(' unlike($_, qr{\Q),(\E}) for @parts; done_testing();