Re: [Tutor] Regular expressions: findall vs search

2012-07-10 Thread Steven D'Aprano
Alexander Q. wrote: My question is how does Python know to return just the part in the parentheses and not to return the "blahblah" and the "yattayattayatta", etc...? The 're.search' function returns the whole thing, and if I want just the parentheses parts, I do tuples.group(1) or tuples.group(

Re: [Tutor] Regular expressions: findall vs search

2012-07-10 Thread Hugo Arts
On Tue, Jul 10, 2012 at 9:26 PM, Alexander Q. wrote: > I'm a bit confused about extracting data using re.search or re.findall. > > Say I have the following code: tuples = > re.findall(r'blahblah(\d+)yattayattayatta(\w+)moreblahblahblah(\w+)over', > text) > > So I'm looking for that string in 'tex

[Tutor] Regular expressions: findall vs search

2012-07-10 Thread Alexander Q.
I'm a bit confused about extracting data using re.search or re.findall. Say I have the following code: tuples = re.findall(r'blahblah(\d+)yattayattayatta(\w+)moreblahblahblah(\w+)over', text) So I'm looking for that string in 'text', and I intend to extract the parts which have parentheses around