Forums / Setup & design / remove CRLF (\r\n) caracters

remove CRLF (\r\n) caracters

Author Message

Lydie Soler

Wednesday 14 December 2005 9:42:05 am

Hi,

does someone knows a way to remove the CRLF (\r\n) caracters from a string?

I have tried almost all the string function but it doesn't seems to work.
here is an example of what I would like:
I have

 line 1
line 2

I would like to have

 line1 line2

I didn't find a replace function or something like this. Thanks a lot for your help! This caracters makes my javascript bug!

Thanks again for your help

Ole Morten Halvorsen

Wednesday 14 December 2005 11:23:01 am

Did you try the <b>trim()</b> operator?

http://ez.no/doc/ez_publish/technical_manual/3_6/reference/template_operators/strings/trim

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Ole Morten Halvorsen

Wednesday 14 December 2005 2:25:05 pm

My bad. Didn't see you wanted to remove newline characters from the middle of the string :)

I think you would have to make your own operator that does the removal for you.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Lydie Soler

Thursday 15 December 2005 12:50:36 am

hi!

yes I have tried the trim operator and as you noticed my problem is with removing caracters in the middle of the string.

ok lets try to create my own... But how do I do this?... where do I have to put my new code....

where can I find the code of the trim operator in order to have an example?

thanks again!!!

Lydie Soler

Thursday 15 December 2005 1:55:01 am

Well I have search.. and I have found an extension that does exactl what I needed: str_replace.

so here is the code that works for my needs:

{set $corps=ezstr_replace("\r","",$corps)}
{set $corps=ezstr_replace("\n","<br/>",$corps)}

Ole Morten Halvorsen

Thursday 15 December 2005 4:12:24 am

That's great.

Didn't know there was a string replace operator available as a contribution :)

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578