[Python-3000] Droping find/rfind?
Georg Brandl
g.brandl at gmx.net
Wed Aug 23 21:36:12 CEST 2006
Steven Bethard wrote:
> Steven Bethard wrote:
>> Could you post a simple example or two?
>
> Josiah Carlson wrote:
>> index = text.find(...)
>> if index >= 0:
>> ...
>>
> [snip]
>> index = 0
>> while 1:
>> index = text.find(..., index)
>> if index == -1:
>> break
>> ...
>>
>
> Thanks. So with your search() function, these would be something like:
>
> indices = text.search(pattern, count=1)
> if indices:
> index, = indices
> ...
Or even
indices = text.search(pattern, count=1)
for index in indices:
...
Georg
More information about the Python-3000
mailing list