Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - Re: iterate lines with regex

 
Thread Tools Search this Thread
Old 08-01-2009, 09:08 PM   #1
Default Re: iterate lines with regex


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 have to be rest to beginning of line? If so, how would I do
> that.
> remember I'm new
> thanks in advance to any advice
> Mike S.
>
> the following is part of my code,
> readThis=open('c:/9320.txt','r')
>
> 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
>
>

The bare except will hide any errors in the lines above it. Either catch
errors that you expect or take the try-except out.

--
Kindest regards.

Mark Lawrence.



Mark Lawrence
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Horizontal Lines on Cartoon dvd's Roger Hammonds DVD Video 1 10-07-2006 03:43 PM
Is there a tool to locate duplicate lines in a file ? rofarmer Software 0 08-17-2006 06:58 PM
Walt Disney Treasures - ON THE FRONT LINES - DVD REVIEW Mike McGee DVD Video 25 05-13-2004 07:06 PM
JVC HRXVC44U DVD/VCR combo and seeing scan lines Eric B DVD Video 0 05-05-2004 07:45 PM
Re: Is Anchor Bay 2nd Best After Criterion ? Grand Inquisitor DVD Video 8 08-23-2003 03:40 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46