Re: New to using re. Search for a number before a string.

2013-11-02 Thread Mark Lawrence
On 03/11/2013 00:19, Captain Dunsel wrote: On Friday, November 1, 2013 5:33:43 PM UTC-4, Captain Dunsel wrote: I have a text file that has lines with numbers occasionally appearing right before a person's name. For example: COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER where

Re: New to using re. Search for a number before a string.

2013-11-02 Thread Captain Dunsel
On Friday, November 1, 2013 5:33:43 PM UTC-4, Captain Dunsel wrote: > I have a text file that has lines with numbers occasionally appearing right > before a person's name. For example: > > > > COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER > > > > where I want to search for the

Re: New to using re. Search for a number before a string.

2013-11-02 Thread Mark Lawrence
On 01/11/2013 21:33, Captain Dunsel wrote: I have a text file that has lines with numbers occasionally appearing right before a person's name. For example: COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER where I want to search for the name "ELMER FUDD" and extract the number right

Re: New to using re. Search for a number before a string.

2013-11-02 Thread Justin Barber
I'm guessing that the name "FUDD, ELMER" varies. In that case, you might try something like this: >>> id_num_regex = re.compile(r'\d+(?=\w+\b,.+?)') >>> id_num_regex.findall(t) ['624309'] This would account for first names such as 'Mary Ann' and also automatically matches characters only to the

Re: New to using re. Search for a number before a string.

2013-11-02 Thread Jussi Piitulainen
Captain Dunsel writes: > I have a text file that has lines with numbers occasionally > appearing right before a person's name. For example: > > COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER > > where I want to search for the name "ELMER FUDD" and extract the > number right in front

Re: New to using re. Search for a number before a string.

2013-11-01 Thread MRAB
On 01/11/2013 21:33, Captain Dunsel wrote: I have a text file that has lines with numbers occasionally appearing right before a person's name. For example: COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER where I want to search for the name "ELMER FUDD" and extract the number right

New to using re. Search for a number before a string.

2013-11-01 Thread Captain Dunsel
I have a text file that has lines with numbers occasionally appearing right before a person's name. For example: COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER where I want to search for the name "ELMER FUDD" and extract the number right in front of it "608309" when such a number a