Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58292

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

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.038
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'example:': 0.03; 'occasionally': 0.09; "person's": 0.09; 'subject:number': 0.09; 'subject:using': 0.09; 'appreciated!': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'appears': 0.22; 'header:User- Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'lines': 0.31; 'extract': 0.31; 'file': 0.32; 'front': 0.32; 'text': 0.33; 'but': 0.35; 'searching': 0.37; 'subject:New': 0.37; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'length': 0.61; 'numbers': 0.61; 'name': 0.63; 'such': 0.63; 'header:Reply- To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'reply- to:addr:python.org': 0.84; 'subject:Search': 0.84; 'subject:before': 0.84; 'captain': 0.91
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=bKAvfpOZ c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=2LCq-pQfA8cA:10 a=AM20Y-Ap3XkA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=NNgP-Q8nmkIA:10 a=pt4bou3kO6IrVr-QssAA:9 a=rbhMW3G-lv9FDUCy:21 a=IdU6qSbWeBOVxwQ9:21 a=wPNLvfGTeEIA:10
X-AUTH mrabarnett:2500
Date Fri, 01 Nov 2013 21:40:17 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.0
MIME-Version 1.0
To python-list@python.org
Subject Re: New to using re. Search for a number before a string.
References <f241bc01-d10a-433f-b3af-b22d05a603d8@googlegroups.com>
In-Reply-To <f241bc01-d10a-433f-b3af-b22d05a603d8@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1940.1383342016.18130.python-list@python.org> (permalink)
Lines 10
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1383342016 news.xs4all.nl 15869 [2001:888:2000:d::a6]:41464
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:58292

Show key headers only | View raw


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!
>
How about searching with a pattern like r':(\d*)FUDD, ELMER'.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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