Split numbers and letters in a string Python -
how split numbers , letters in string? if given:
string = "12really happy15blob" splitstring = [] splitstring = mysplitter(string) print splitstring would homecoming ["12","really happy","15","blob"]
you utilize re.split here:
>>> import re >>> re.split(r'(\d+)', "12really happy15blob") ['', '12', 'really happy', '15', 'blob'] note empty string splitting between start of string , initial 12. you'd have filter out if didn't want it.
python
No comments:
Post a Comment