in reply to Converting BCBCBCBCBCCCB to (BC)^{5}CCB
This is runlength encoding(RLE),
searching the web for such might help.
There is mention of a perl module
Marshal::Packed (by MUIR)
which does RLE, but it is does not
appear to be available anywhere.