perl -le 'print"@{[split/\0/,join qq(\0x),split/(?<=c)/,join(qq(0),qw(a b c d c e foo f)),2]}"' a b c x d c e foo f