newbie question - handling strings
Hi there, I've got an 8-character string, say str='12345678'. With <dtml-var str> ofcourse I get 12345678. How can I display only part of it ? Say the first 4 chars (1234) or the next 2 (56) or the last two (78). In python I know this can be done with something like str[:4], str[4:6] and str[6:]. Any help ? (Hope I didn't sound too newbish !). --- Dimitris Andrakakis http://atlas.central.ntua.gr:8000/~mc94068 __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com
Dimitris Andrakakis wrote:
Hi there, I've got an 8-character string, say str='12345678'. With <dtml-var str> ofcourse I get 12345678. How can I display only part of it ? Say the first 4 chars (1234) or the next 2 (56) or the last two (78). In python I know this can be done with something like str[:4], str[4:6] and str[6:]. Any help ? (Hope I didn't sound too newbish !). --- Dimitris Andrakakis http://atlas.central.ntua.gr:8000/~mc94068
<dtml-var "str[:4]"> or whatever else you want should work. ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres@corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------
<dtml-var expr="some_string[3:9]"> ----- Original Message ----- From: Andres Corrada <andres@corrada.com> To: Dimitris Andrakakis <dandraka_info@yahoo.com> Cc: <zope@zope.org> Sent: Sunday, March 26, 2000 9:34 PM Subject: Re: [Zope] newbie question - handling strings Dimitris Andrakakis wrote:
Hi there, I've got an 8-character string, say str='12345678'. With <dtml-var str> ofcourse I get 12345678. How can I display only part of it ? Say the first 4 chars (1234) or the next 2 (56) or the last two (78). In python I know this can be done with something like str[:4], str[4:6] and str[6:]. Any help ? (Hope I didn't sound too newbish !). --- Dimitris Andrakakis http://atlas.central.ntua.gr:8000/~mc94068
<dtml-var "str[:4]"> or whatever else you want should work. ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres@corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------ _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hi, Dimitris Dimitris Andrakakis wrote:
Hi there, I've got an 8-character string, say str='12345678'. With <dtml-var str> ofcourse I get 12345678. How can I display only part of it ? Say the first 4 chars (1234) or the next 2 (56) or the last two (78). In python I know this can be done with something like str[:4], str[4:6] and str[6:]. Any help ? (Hope I didn't sound too newbish !).
If you want to use pythonish expressions in a dtml-var tag, just quote them. e.g., <dtml-var expr="myStr[:4]"> will get you the first four characters of string myStr. The 'expr=' part is optional. -- Jim Washington Center for Assessment, Evaluation and Educational Programming Department of Teaching and Learning, Virginia Tech
participants (4)
-
Andres Corrada -
Dimitris Andrakakis -
Jim Sanford -
Jim Washington