Re: iterate lines with regex

2009-08-03 Thread Carl Banks
On Aug 3, 11:44 am, Robert Kern wrote: > On 2009-08-03 12:29, MRAB wrote: > > > > > > > Robert Kern wrote: > > [snip] > > >> for line in readThis: > >> key_match = key.search(line) > >> if key_match is not None: > >> this_key = key_match.group(1) > >> # ... do something with this_key > >> map_matc

Re: iterate lines with regex

2009-08-03 Thread Robert Kern
On 2009-08-03 12:29, MRAB wrote: Robert Kern wrote: [snip] for line in readThis: key_match = key.search(line) if key_match is not None: this_key = key_match.group(1) # ... do something with this_key map_match = map.search(line) if map_match is not None: this_map = map_match.group(1) # ... do so

Re: iterate lines with regex

2009-08-03 Thread MRAB
Robert Kern wrote: [snip] for line in readThis: key_match = key.search(line) if key_match is not None: this_key = key_match.group(1) # ... do something with this_key map_match = map.search(line) if map_match is not None: this_map = map_match.group(1)

Re: iterate lines with regex

2009-08-03 Thread Robert Kern
On 2009-08-01 14:39, Michael Savarese wrote: I'm a python newbie and I'm trying to test several regular expressions on the same line before moving on to next line. it seems to move on to next line before trying all regular expressions which is my goal. it only returns true for first regular expr

Re: iterate lines with regex

2009-08-01 Thread Mark Lawrence
Michael Savarese wrote: I'm a python newbie and I'm trying to test several regular expressions on the same line before moving on to next line. it seems to move on to next line before trying all regular expressions which is my goal. it only returns true for first regular expression does the curser

Re: iterate lines with regex

2009-08-01 Thread Jochen Schulz
Michael Savarese: > > for line in readThis: > try: > thisKey = key.search(line).group(1) > thisMap = map.search(line).group(1) > thisParcel = parcel.search(line).group(1) > except: > continue Why do you catch all exceptions in that loop? Remove the try-exce

iterate lines with regex

2009-08-01 Thread Michael Savarese
I'm a python newbie and I'm trying to test several regular expressions on the same line before moving on to next line. it seems to move on to next line before trying all regular expressions which is my goal. it only returns true for first regular expression does the curser have to be rest to beginn