All pastes #619407 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-07-14 18:27 UTC
rendered paste body
def findsubstr(text, substr):
    """findsubstr(text, substr) - returns an iterator of positions of substr within text"""
    position = text.find(substr)
    while position != -1:
        yield position
        position = text.find(substr, position+1)