New to using re. Search for a number before a string.
Mark Lawrence
breamoreboy at yahoo.co.uk
Sat Nov 2 20:27:43 EDT 2013
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 I want to search for the name "ELMER FUDD" and extract the number right in front of it "608309" when such a number appears but the length of the number is variable and using ?<= in a regular expression will only search for a fixed length.
>>
>>
>>
>> Any ideas appreciated!
>
> Thanks for your help, everyone!
>
My invoice, like the proverbial cheque, is in the post :)
Slight aside, in order to avoid the unwanted newlines above could you
please read and action this, thanks
https://wiki.python.org/moin/GoogleGroupsPython
--
Python is the second best programming language in the world.
But the best has yet to be invented. Christian Tismer
Mark Lawrence
More information about the Python-list
mailing list