Help for this page
my $a = "xx|xx|xx|xxxx|xx|xxx|xx|xx|xx"; $a =~ s/(?<=\|)xx(?=(\||$))/x x/g; print $a; __DATA__ xx|x x|x x|xxxx|x x|xxx|x x|x x|x x
$a =~ s/(?<=\|)|^xx(?=(\||$))/x x/g; ... # if they exist in practice as your real data is no doubt # not really xx..... $a =~ s/\bxx\b/x x/g;