Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58327
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: New to using re. Search for a number before a string. |
| Date | 2013-11-02 13:31 +0000 |
| References | <f241bc01-d10a-433f-b3af-b22d05a603d8@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1952.1383399138.18130.python-list@python.org> (permalink) |
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 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 http://docs.python.org/3/howto/regex.html, https://wiki.python.org/moin/RegularExpression and http://www.regular-expressions.info/python.html Also, the new regex package is an alternative to the stdlib re package. It's available from https://pypi.python.org/pypi/regex -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
New to using re. Search for a number before a string. Captain Dunsel <jonathan.nyquist@gmail.com> - 2013-11-01 14:33 -0700
Re: New to using re. Search for a number before a string. MRAB <python@mrabarnett.plus.com> - 2013-11-01 21:40 +0000
Re: New to using re. Search for a number before a string. Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-11-02 09:06 +0200
Re: New to using re. Search for a number before a string. Justin Barber <jbarber@iliff.edu> - 2013-11-02 06:03 -0700
Re: New to using re. Search for a number before a string. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-02 13:31 +0000
Re: New to using re. Search for a number before a string. Captain Dunsel <jonathan.nyquist@gmail.com> - 2013-11-02 17:19 -0700
Re: New to using re. Search for a number before a string. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-03 00:27 +0000
csiph-web