Karl Schmid wrote: > Is there a more elegant solution to this problem than the following one? > > >>> import re > >>> a = 'This module provides regular expression matching operations > similar to those found in Perl' > >>> import re > >>> p = re.compile('(o)') > >>> pos = 0 > >>> while p.search(a, pos): > ... pos = p.search(a, pos).start() > ... print pos > ... pos += 1 better make that loop: while 1: m = p.search(a, pos) if not m: break pos = m.start() print pos pos += 1 Cheers /F
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4