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


Groups > comp.lang.python > #20510

Re: Reading sub-string from a file

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'think,': 0.05; 'names.': 0.07; 'subject:string': 0.09; 'substring': 0.09; 'subject:file': 0.13; '16,': 0.15; '4321': 0.16; 'char,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'grep': 0.16; 'int);': 0.16; 'this:': 0.16; 'wrote:': 0.18; 'int': 0.18; 'received:209.85.210.174': 0.21; 'received:mail- iy0-f174.google.com': 0.21; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'int,': 0.23; 'ignore': 0.24; 'extract': 0.24; 'function': 0.27; 'message-id:@mail.gmail.com': 0.29; "skip:' 10": 0.29; 'pm,': 0.29; '---': 0.31; 'remaining': 0.32; 'thu,': 0.32; 'to:addr:python-list': 0.35; 'something': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'skip:" 10': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'subject:from': 0.39; 'received:209': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40; 'here': 0.64; 'wish': 0.68; 'onwards': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=AdmGZO73dB6i7HDOaN9bt4v/AebuVpkvFghDSt07efg=; b=AQpB2H1rCl0xUxhgNMGY2Lg33Iz4qMx08cZZennCRZNsfGx8BcTglWvaB13ZMGyioF A0OgLZqhYn3POyS7cDMb0Uwv92qeqO0Q4OdrCWP+xJwWSW3l+hT1uDr2KQaX5fJOWq+l ntmXC3tAM/uGiJNfFR+D1WoymkGmR9g6t38KA=
MIME-Version 1.0
In-Reply-To <CAJ1erZ1izVQVHQj3tt4y5HoumQv0bM9qDp40fMehKzYewnfUVQ@mail.gmail.com>
References <CAJ1erZ1izVQVHQj3tt4y5HoumQv0bM9qDp40fMehKzYewnfUVQ@mail.gmail.com>
Date Thu, 16 Feb 2012 21:32:10 +1100
Subject Re: Reading sub-string from a file
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5884.1329388334.27778.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1329388334 news.xs4all.nl 6901 [2001:888:2000:d::a6]:34696
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20510

Show key headers only | View raw


On Thu, Feb 16, 2012 at 8:52 PM, Smiley 4321 <ssmile03@gmail.com> wrote:
> int Jockey_Apple_cat_1KK(float, int, char, int);
> int Jockey_Apple_cat_look(int, float, int, int);
> int Jockey_Apple_cat_test_ki21es(int, int, int, int);
> int Jockey_Apple_cat_tarLK12OU(void, int, int, int);
> ---
>
> Here substring "Jockey_Apple_cat" is common from 3rd line onwards as a
> function name. I wish to extract ONLY that function name which has
> 'Jockey_Apple_cat' as a substring and ignore remaining function names.

Try this:

grep -o 'Jockey_Apple_cat[^(]*' test.conf

It's not Python, but it might serve you better than knocking something
together! But if you're using this to learn Python, Peter Otten's
solution is, I think, what you want.

ChrisA

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


Thread

Re: Reading sub-string from a file Chris Angelico <rosuav@gmail.com> - 2012-02-16 21:32 +1100

csiph-web