use strict; use warnings; my $string = "a,bc,d,efg"; if( $string =~ m/(?:,[^,]*){2}(,)/ ) { print $'; }