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


Groups > comp.lang.python > #38974

Re: Howto parse a string using a char in python

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.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; 'character,': 0.07; 'expressions': 0.07; 'subject:string': 0.09; 'subject:using': 0.09; 'cc:addr:python-list': 0.10; 'looked': 0.10; 'subject:python': 0.11; 'steve': 0.13; '":"': 0.16; '-tkc': 0.16; 'enough.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'function(s)': 0.16; 'string': 0.17; 'wrote:': 0.17; 'parse': 0.22; 'cc:2**0': 0.23; 'needed.': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'regular': 0.27; 'colon': 0.29; 'python2.7': 0.29; 'character': 0.29; 'function': 0.30; 'hi,': 0.33; 'something': 0.35; 'charset :us-ascii': 0.36; 'far': 0.37; 'subject:: ': 0.38; 'skip:" 10': 0.40; 'sounds': 0.71; 'received:50.22': 0.84; 'received:108': 0.91
Date Fri, 15 Feb 2013 17:16:26 -0600
From Tim Chase <python.list@tim.thechases.com>
To "Steve Goodwin" <sgoodwin@cfl.rr.com>
Subject Re: Howto parse a string using a char in python
In-Reply-To <511ebf0c$0$21334$9a6e19ea@unlimited.newshosting.com>
References <511ebf0c$0$21334$9a6e19ea@unlimited.newshosting.com>
X-Mailer Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.1857.1360970107.2939.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1360970107 news.xs4all.nl 6888 [2001:888:2000:d::a6]:37700
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:38974

Show key headers only | View raw


On 2013-02-15 18:04, Steve Goodwin wrote:
> Hi,
> 
> I am looking for the python2.7 function(s) to parse a string from a
> colon character ":"
> 
> Sounds simple enough.
> 
> For example, a string like "123456:789".  I just need the "123456" 
> substring.(left of the :)
> 
> I have looked at regular expressions and string functions, so far
> no luck. Custom function required?

With just a single character, it sounds like you want something like

  whole = "123456:789"
  parts = whole.split(':') # or .split(':', 1)
  interesting = parts[0]

No custom function needed.

-tkc


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


Thread

Howto parse a string using a char in python "Steve Goodwin" <sgoodwin@cfl.rr.com> - 2013-02-15 18:04 -0500
  Re: Howto parse a string using a char in python John Gordon <gordon@panix.com> - 2013-02-15 23:11 +0000
  Re: Howto parse a string using a char in python Tim Chase <python.list@tim.thechases.com> - 2013-02-15 17:16 -0600
  Re: Howto parse a string using a char in python David Robinow <drobinow@gmail.com> - 2013-02-15 18:19 -0500
  Re: Howto parse a string using a char in python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-15 23:20 +0000
  Re: Howto parse a string using a char in python Gary Chambers <gwchamb@gwcmail.com> - 2013-02-15 18:13 -0500

csiph-web