[Zope] Newbie: String work

Geir Bækholt Geir Bækholt <geirh@funcom.com>
Tue, 27 Jun 2000 14:37:59 +0200


on Tuesday, June 27, 2000 Andy Gates wrote :
AG> Simple stuff from the simple people today: string manipulation.

AG> I have a string variable which has various chunks delimited by double 
AG> tildes ~~. In order to do what I need to do, I need to extract the 
AG> section of the string after the last double-tilde, so that

AG> "fred~~bloggs" returns "bloggs"
AG> "fred" returns "fred"
AG> "fred~~bloggs~aardvark" returns "aardvark"

AG> I can see that rfind is the thing I need to use, but as usual (gah! 
AG> newbie!) I'm stuck on the syntax.  Help!

try something like :

<dtml-var expr="_.string.split('fred~~bloggs','~~')[-1]">

this is documented at
http://www.zope.org/Documentation/Guides/DTML-HTML/DTML.4.4.2.3.html
 - but not very newbie-friendly

 took me a long time to figure out how to use :-)

--
Geir Bækholt
web-developer/designer
geirh@funcom.com
http://www.funcom.com