String Manipulation

Bengt Richter bokr at oz.net
Wed Jul 16 13:20:52 EDT 2003


On 15 Jul 2003 19:51:56 -0700, ee01b092 at ee.iitm.ernet.in (Vinoo Vasudevan) wrote:

>lamar_air at hotmail.com (lamar_air) wrote in message news:<2c6431ab.0307151223.4173c4ee at posting.google.com>...
>> I need a piece of code that takes a string like this string1 =
>> "aaa/bbb/ccc/dd" and extracts a string containting the character after
>> the last "/"
>> 
>> So for this example the result would be "dd"
>> 
>> like this:
>> for i=0; string1.right(i) != '/'; i++
>> 
>> result = string1.mid(i, string1.length())
>> 
>> but in python.
>
>How about this: 
>string1 = 'aaa/bbb/ccc/dd'
>result = string1[string1.rfind('/')+1:]
>
>Hope it's helpful,
Sorry Vinoo, for some reason your post did not show up for me before I posted
the same solution, even though your post is dated much before mine.
I guess it has to do with delays in news servers forwarding and such.

Regards,
Bengt Richter




More information about the Python-list mailing list