----- Original Message ----- From: Andy Gates <Andy.Gates@bristol.ac.uk> To: <zope@zope.org> Sent: Tuesday, June 27, 2000 1:39 PM Subject: [Zope] Newbie: String work
Simple stuff from the simple people today: string manipulation.
I have a string variable which has various chunks delimited by double tildes ~~. In order to do what I need to do, I need to extract the section of the string after the last double-tilde, so that
"fred~~bloggs" returns "bloggs" "fred" returns "fred" "fred~~bloggs~aardvark" returns "aardvark"
I can see that rfind is the thing I need to use, but as usual (gah! newbie!) I'm stuck on the syntax. Help!
Maybe is a little strange , but should work (I hope:) <dtml-let a="'abc~~ABC~~s'"> <dtml-var "a[((_.string.rfind(a,'~~')+1) or-1 )+1:]"> </dtml-let> Or maybe is better to use split, is more readable <dtml-var "_.string.split(a,'~~')[-1]"> PM