On Sun, 18 May 2008 20:30:57 +0100, Peter Otten <[EMAIL PROTECTED]> wrote:
Matt Porter wrote:
I'm trying to compress a string.
E.g:
"AAAABBBC" -> "ABC"
Two more:
from itertools import groupby
"".join(k for k, g in groupby("aaaaaabbbbbbbbbbcccccc"))
'abc'
import re
re.compile(r"(.)\1*").sub(r"\1", "aaaaaaabbbbcccccccc")
'abc'
Brilliant - I was trying to figure out how to do this with the re
capabilities.
Thanks to everyone
Peter
--
http://mail.python.org/mailman/listinfo/python-list
--
--
--
http://mail.python.org/mailman/listinfo/python-list