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


Groups > comp.lang.python > #45434

Re: spilt question

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 <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.042
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'one?': 0.05; 'string': 0.09; 'underscore': 0.09; 'subject:question': 0.10; 'received:74.208.4.195': 0.16; 'wrote:': 0.18; 'split': 0.19; 'header:User-Agent:1': 0.23; 'appreciated': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'am,': 0.29; 'work.': 0.31; 'cases': 0.33; 'but': 0.35; 'method': 0.36; 'should': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; "you're": 0.61; 'complete': 0.62; 'more': 0.64; 'received:74.208': 0.68; 'partial': 0.84
Date Thu, 16 May 2013 11:20:25 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5
MIME-Version 1.0
To python-list@python.org
Subject Re: spilt question
References <d8c03de0-dc35-45e3-a6b2-2af39feb9e79@googlegroups.com>
In-Reply-To <d8c03de0-dc35-45e3-a6b2-2af39feb9e79@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:crX4X3k7fI3u8eV5M6Lc0lyxTnEf3kKHfa6+QUXqN78 kkmWFOr6mt2aQG1Z3cx/g+41QaAlSuW+abmICdi1un/ZShNeov +JEiAdS9ek626LdiPQ8ZqTSjImofdQwZq+J57SpfuEizyN6tBu nYt5M23jyW49fjcikssOBS6EJgZCKpk5B2DU/nCP1316reAiZb HlNOLPFjW7mPm4cTNyjlTkydlF9p+zt9+XmM7gxZtrR7TZnmbn TjU+5EropMPvohfiukOBOPSUBq1crLTyhefQsEXo27yP2+c+dM pM6iXhPG8DVGELjdM8dLxCH0KGcQJf01pgKWf6+C7AiN4vpZw= =
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.1759.1368717643.3114.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368717643 news.xs4all.nl 15934 [2001:888:2000:d::a6]:39680
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45434

Show key headers only | View raw


On 05/16/2013 11:00 AM, 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
>

The rsplit() method was a good idea; it will work.  So exactly what did 
you try and what about it did not work.  How are you stuck going from 
your partial answer to a complete one?

While you're at it, you need to consider at least two more cases

HELLO.txt                    #should return ""
HELLO_and_____goodbye        #should return "HELLO_and____"

-- 
DaveA

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


Thread

spilt question loial <jldunn2000@gmail.com> - 2013-05-16 08:00 -0700
  Re: spilt question Walter Hurry <walterhurry@lavabit.com> - 2013-05-16 15:10 +0000
  Re: spilt question Fábio Santos <fabiosantosart@gmail.com> - 2013-05-16 16:14 +0100
  Re: spilt question Chris Angelico <rosuav@gmail.com> - 2013-05-17 01:15 +1000
  Re: spilt question Dave Angel <davea@davea.name> - 2013-05-16 11:20 -0400
  Re: spilt question Tim Chase <python.list@tim.thechases.com> - 2013-05-16 10:23 -0500
  Re: spilt question Ned Batchelder <ned@nedbatchelder.com> - 2013-05-16 11:22 -0400
  Re: spilt question Dave Angel <davea@davea.name> - 2013-05-16 11:32 -0400

csiph-web