Extracting subsequences composed of the same character
candide at free.invalid
Fri Apr 1 02:43:38 CEST 2011
Suppose you have a string, for instance
"pyyythhooonnn ---> ++++"
and you search for the subquences composed of the same character, here
you get :
'yyy', 'hh', 'ooo', 'nnn', '---', '++++'
It's not difficult to write a Python code that solves the problem, for
if not text:
for c in ch:
print f("pyyythhooonnn ---> ++++")
I should confess that this code is rather cumbersome so I was looking
for an alternative. I imagine that a regular expressions approach could
provide a better method. Does a such code exist ? Note that the string
is not restricted to the ascii charset.
More information about the Python-list