In sed:
echo stackoverflow | sed 's/./&,/1;s/./&,/3;s/./&,/5'
s/.../.../nreplaces the nth match. After the first replacement, the second byte will now be the third, and after that the third byte will now be the fifth.
, :
echo stackoverflow | sed 's/\(.\)\(.\)\(.\)/\1,\2,\3,/'
Basic Regular Expressions (BRE) \(…\). , n- , \n, , . , , ..
GNU sed \ (ERE):
echo stackoverflow | sed -r 's/(.)(.)(.)/\1,\2,\3,/'
C:
$ echo 'æ ' | LC_ALL=C sed 's/\(.\)\(.\)\(.\)/\1,\2,\3,/'
, , ,
$ echo → | LC_ALL=C sed 's/\(.\)\(.\)\(.\)/\1,\2,\3,/'
, , ,