Am Donnerstag, den 14.07.2005, 16:00 -0400 schrieb Asad Habib:
Is it possible to replace more than 1 type of character in a string
simultaneously? If so, what is the correct syntax for this? I am currently
using the following:
dtml-var _.string.replace(testString, _.chr(10), 'br /')
For this string, I want to replace both newlines and carriage returns
(_.chr(13)) with the break tag.
IIRC. you can just use dtml-var testString newline_to_br
to get the same result.
I know of no occurence where you have either \n or \r
but in the same string (and not just \n or \n\r)
But if you want to replace each, either:
dtml-var expr=testString.replace('\r','\n') newline_to_br
or
dtml-var
expr=testString.replace('\n','br /').replace('\r','br /')
but beware the quoting.
Even better maybe you just use CSS for your layout:
p style=white-space:pre
dtml-var testString
/p
or with ZPT:
p style=white-space:pre tal:content=options/testString
Sampletext
/p
___
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )