Search substring in a string and get index of all occurances
nicogrubert at gmail.com
Wed Jun 21 10:28:58 CEST 2006
I would like to search for a substring in a string and get the index of
mystring = 'John has a really nice powerbook.'
substr = ' ' # space
I would like to get this list:
[4, 8, 10, 17, 22]
How can I do that without using "for i in mystring" which might be
expensive for large strings?
Thanks in advance,
More information about the Python-list