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: 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 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: In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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