$_ = 'xaxbxcxdexfxxxx'; print $1 while /(?<=x)(.)(?=x)/g; # abcfxx