spilt question
Dave Angel
davea at davea.name
Thu May 16 11:20:25 EDT 2013
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
More information about the Python-list
mailing list