Searching in str backwards

Chris Kaynor ckaynor at zindagigames.com
Thu Oct 14 01:38:14 CEST 2010


Look up the string's rfind method.

Chris


On Wed, Oct 13, 2010 at 4:28 PM, Pratik Khemka <pratikkhemka at hotmail.com>wrote:

>  I  want to search for a symbol in a string backwards..
> For eg:
>
> *line = "my/cat/dog/baby"*
> **
> *line.find('/')* *# but from the back...*
>
> The reason I want to do this is because I want to print the last part of
> the string after the '/' . And I do not know how long the string might be or
> how many '/' it might have . I just want to print whatever is there after
> the last '/'.
>
> Thanks,
> Pratik
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101013/172e630f/attachment.html>


More information about the Python-list mailing list