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

Mark Lawrence breamoreboy at
Sat Nov 2 14:31:59 CET 2013

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:
> 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!

As you've had answers here's some references for future use, and

Also, the new regex package is an alternative to the stdlib re package. 
  It's available from

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