Re: [Tutor] re.search() help

2012-04-15 Thread Walter Prins
Hi Michael, On 16 April 2012 01:20, Michael Lewis wrote: > So that you can find the section of a long string that >> first matches your regex. >> >> > Why not use re.findall() for that? It seems like re.findall() can fill > this need and I wouldn't need to use re.search()? Can you compare an > e

Re: [Tutor] re.search() help

2012-04-15 Thread Alan Gauld
On 16/04/12 00:20, Michael Lewis wrote: > What is the purpose of this? So that you can find the section of a long string that first matches your regex. Why not use re.findall() for that? It seems like re.findall() can fill this need and I wouldn't need to use re.search()? Can you

Re: [Tutor] re.search() help

2012-04-15 Thread Michael Lewis
> > Message: 6 > Date: Sun, 15 Apr 2012 08:48:10 +0100 > From: Alan Gauld > To: tutor@python.org > Subject: Re: [Tutor] re.search() help > Message-ID: > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 15/04/12 08:10, Michael Lewis wrote: >

Re: [Tutor] re.search() help

2012-04-15 Thread Alan Gauld
On 15/04/12 08:10, Michael Lewis wrote: Hi everyone, I am a bit confused on how one would ever use re.search(). It essentially tells me the location on (RAM?) if the pattern matches? No it returns a MatchObject instance. You can then perform various operations on the MatchObject to, for exampl

[Tutor] re.search() help

2012-04-15 Thread Michael Lewis
Hi everyone, I am a bit confused on how one would ever use re.search(). It essentially tells me the location on (RAM?) if the pattern matches? What is the purpose of this? Can you give me a good example of where it would be useful? Thanks! re.search(*pattern*, *string*, *flags=0*)