String Manipulation
Batista, Facundo
FBatista at uniFON.com.ar
Tue Jul 15 17:03:07 EDT 2003
>>> orig = "aaa/bbb/ccc/dd"
>>> orig.split('/')[orig.count('/')]
'dd'
>>>
. Facundo
#- -----Mensaje original-----
#- De: lamar_air at hotmail.com [mailto:lamar_air at hotmail.com]
#- Enviado el: Martes 15 de Julio de 2003 5:23 PM
#- Para: python-list at python.org
#- Asunto: String Manipulation
#-
#-
#- 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.
#- --
#- http://mail.python.org/mailman/listinfo/python-list
#-
More information about the Python-list
mailing list