"how can I manage it to cut a string. for example: a string property (testtext) with 500 words. but only want to give out 20 characters of tis text." Python sequence slicing syntax can be done with DTML, like so: <dtml-call "REQUEST.set('first_20_char', '_['some_long"string'][:20])"> <dtml-var first_20_char> wher the '[:20]' means from the begining of the string, through the 20th "slice". One thing to be aware of is that the positions start counting at 0, and are best thought of as falling "between" the individual characters, like so: a b c d e f g 0 1 2 3 4 5 6 7 So the 20th position ('slice') is just past the 19th character, if the first character is counted as 0.
On Wed, 27 Sep 2000, Spicklemire, Jerry wrote:
"how can I manage it to cut a string.
for example:
a string property (testtext) with 500 words.
but only want to give out 20 characters of tis text."
Python sequence slicing syntax can be done with DTML, like so:
<dtml-call "REQUEST.set('first_20_char', '_['some_long"string'][:20])"> <dtml-var first_20_char>
wher the '[:20]' means from the begining of the string, through the 20th "slice". One thing to be aware of is that the positions start counting at 0, and are best thought of as falling "between" the individual characters, like so:
a b c d e f g 0 1 2 3 4 5 6 7
So the 20th position ('slice') is just past the 19th character, if the first character is counted as 0.
or.. i think 2.2.x has size as in <dtml-var myobject size=20> correct me if i'm wrong though -- http://www.kedai.com.my/kk http://www.kedai.com.my/eZine I will follow you! ..Damage Inc
participants (2)
-
Bak @ kedai -
Spicklemire, Jerry