searching through a string and pulling characters

Alexnb alexnbryan at
Mon Aug 18 22:40:13 CEST 2008

This is similar to my last post, but a little different. Here is what I would
like to do.

Lets say I have a text file. The contents look like this, only there is A
LOT of the same thing. 

() A registry mark given by underwriters (as at Lloyd's) to ships in
first-class condition. Inferior grades are indicated by A 2 and A 3.
() The first three letters of the alphabet, used for the whole alphabet.
() In church or chapel style; -- said of compositions sung in the old church
style, without instrumental accompaniment; as, a mass a capella, i. e., a
mass purely vocal.
() Astride; with a part on each side; -- used specif. in designating the
position of an army with the wings separated by some line of demarcation, as
a river or road.

Now, I am talking 1000's of these. I need to do something like this. I will
have a number, and what I want to do is go through this text file, just like
the example. The trick is this, those "()'s" are what I need to match, so if
the number is 245 I need to find the 245th () and then get the all the text
from after it until the next (). If you have an idea about the best way to
do this I would love your help. If you made it all the way through thanks!
View this message in context:
Sent from the Python - python-list mailing list archive at

More information about the Python-list mailing list