[Zope] String manipulation

2000-09-26 Thread jensebaer



Hi all,

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.

Thank you

Jens


Re: [Zope] String manipulation

2000-09-26 Thread Phil Harris

Jens,

You have a few options:

1.Cut the string, dtml-var "the_string[:20]
2.Use the size option of dtml-var, dtml-var the_string size=20
etc="..."

hth

Phil (ex. twinky-salesman)
[EMAIL PROTECTED]

- Original Message -
From: jensebaer
To: [EMAIL PROTECTED]
Sent: Tuesday, September 26, 2000 8:28 PM
Subject: [Zope] String manipulation


Hi all,

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.

Thank you

 Jens


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




[Zope] String manipulation

2000-09-26 Thread Spicklemire, Jerry

"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.

___
Zope maillist  -  [EMAIL PROTECTED]
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 )