Is in the Python something like method findNext() in string?
10,335
The find-Method has a start
-argument:
text = "John got up. John went to the cinema. John washed his hand."
pos = -1
while True:
pos = text.find('John', pos + 1)
if pos == -1:
break
do_something
Author by
user2104552
Updated on June 04, 2022Comments
-
user2104552 almost 2 years
E.g. I have got text:
"John got up. John went to the cinema. John washed his hand."
Now I would like to find first "John" and do something, then I would like to go to next "John" and do something, so I need to use something like
findNext()
, which considers the actual position, so it will not be finding from the beginning, but from the actual position.