[Tutor] finding a number with str.find

Alan Gauld alan.gauld at btinternet.com
Mon Oct 8 22:59:24 CEST 2012

On 08/10/12 19:31, Steven D'Aprano wrote:

> re.search(r'\d', 'I 8 sandwiches').start()
> # returns 2

I knew there was a better way that using index
and group but I couldn't think what it was...

start() so obvious once you see it :-)

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list