split string into multi-character "letters"
jpiitula at ling.helsinki.fi
Wed Aug 25 22:05:39 CEST 2010
> alphabet = ['a','b','c','ch','d','u','r','rr','o'] #this would
> include the whole alphabet but I shortened it here
> theword = 'churro'
> I would like to split the string 'churro' into a list containing:
All non-overlapping matches, each as long as can be, and '.' catches
single characters by default:
>>> import re
>>> re.findall('ch|ll|rr|.', 'churro')
['ch', 'u', 'rr', 'o']
More information about the Python-list