[Zope] Re[2]: [Zope] splitting strings ??
Geir B Hansen
Geir B Hansen <geirh@funcom.com>
Thu, 6 Jan 2000 13:48:58 +0100
on 6. januar 2000 Jens Vagelpohl wrote :
JV> hi geir,
JV> i assume you're referring to the last element of the split-up string, not
JV> the last character, right?
JV> if i remember right from those great o'reilly books about python the last
JV> element in a list (which is what you get from a split operation) can be
JV> referred to by <mylistname>[-1], so your example would look like:
JV> <dtml-if expr="_.string.split(_['REMOTE_ADDR'],'.')[-1] == '71'">
JV> this works because you can count up from the first element ([0], [1] etc) or
JV> down from the last ([-1], [-2]) by using negative indexes.
JV> jens
thanks for the info about the negative numbers (nice to know), but i am actually
looking for the last character of a string..
sorry for my lousy explanation in the first mail.
i'll get the o'reilley-book on python as fast as i can.. Promise !!
--
Geir B Hansen
web-developer/designer
geirh@funcom.com
http://www.funcom.com