> > Message: 6 > Date: Sun, 15 Apr 2012 08:48:10 +0100 > From: Alan Gauld <alan.ga...@btinternet.com> > To: tutor@python.org > Subject: Re: [Tutor] re.search() help > Message-ID: <jmdufr$478$1...@dough.gmane.org> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > 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 example find the substring > which actually matched. > > > 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 compare an example circumstance where one would be better suited than the other? > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > -- Michael J. Lewis mjole...@gmail.com
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor