Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'string': 0.09; 'underscore': 0.09; 'subject:question': 0.10; 'cc:addr:python- list': 0.11; 'argument.': 0.16; 'wrote:': 0.18; 'split': 0.19; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'appreciated': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'work.': 0.31; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'skip:& 10': 0.38; 'url:mail': 0.40; 'skip:y 20': 0.60; 'to:addr:gmail.com': 0.65; 'limit': 0.70; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=uJfpIN7TyNAF3oD3P5bL4ZL6Zc3pTAgjZwIpwZ6sJtU=; b=CVxaD6iGauet0KsqY1ffI8ym5Bj86FrkBkbOheWucTkxubQG8euJAnLDL75YCTeSj/ qNZms2nCb/ChzEOOUmoE/Sv54niVDjSSm+ZR9ZjkY9zi0RT46TMzP8r0LpvQIxscZJNp Zjl6ayOO/Nope/tAvlXum4McftePdHsuKtiBixpWVruw8G4jLbRLq2099E0kmvtw0G9a iKNbzQGOW7TiCF9rHNRtYtZMNxFtitJ3+ZEv13Hp34bK3eDYyp/XiouKBZFSJe8XER1N sLY20iJi7c1oqN5c/3yf294QhtZw00ymjjdqfRiPLmELq55WSdaMkXKSE5JHs+D3Sfic GR5w== MIME-Version: 1.0 X-Received: by 10.229.135.10 with SMTP id l10mr13644840qct.82.1368717267268; Thu, 16 May 2013 08:14:27 -0700 (PDT) In-Reply-To: References: Date: Thu, 16 May 2013 16:14:27 +0100 Subject: Re: spilt question From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: loial Content-Type: multipart/alternative; boundary=00248c7690aa83a0ec04dcd752ba 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368717276 news.xs4all.nl 15984 [2001:888:2000:d::a6]:34996 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45431 --00248c7690aa83a0ec04dcd752ba Content-Type: text/plain; charset=ISO-8859-1 str.split takes a limit argument. Try your_string.split('_', 1) On 16 May 2013 16:11, "loial" wrote: > I want to split a string so that I always return everything BEFORE the > LAST underscore > > HELLO_xxxxxxxx.lst # should return HELLO > HELLO_GOODBYE_xxxxxxxx.ls # should return HELLO_GOODBYE > > I have tried with rsplit but cannot get it to work. > > Any help appreciated > > -- > http://mail.python.org/mailman/listinfo/python-list > --00248c7690aa83a0ec04dcd752ba Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

str.split takes a limit argument. Try your_string.split(= 9;_', 1)

On 16 May 2013 16:11, "loial" <jldunn2000@gmail.com> wrote:
I want to split a string so that I always return everything BEFORE the LAST= underscore

HELLO_xxxxxxxx.lst =A0 =A0 =A0 =A0 # should return HELLO
HELLO_GOODBYE_xxxxxxxx.ls =A0# should return HELLO_GOODBYE

I have tried with rsplit but cannot get it to work.

Any help appreciated

--
http://mail.python.org/mailman/listinfo/python-list
--00248c7690aa83a0ec04dcd752ba--