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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 00:59:22
Script start
Timing: Jan 18 2025 00:59:22
Module start 'layout'
Timing: Jan 18 2025 00:59:22
Module start 'content'
Timing: Jan 18 2025 00:59:23
Module end 'content'
Timing: Jan 18 2025 00:59:23
Script end

Main resources:

Total runtime0.7100 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0090 587.9219152.6250
Module start 'layout' 0.00900.0056 740.546939.4453
Module start 'content' 0.01460.6938 779.9922531.3750
Module end 'content' 0.70840.0016 1,311.367216.1641
Script end 0.7100  1,327.5313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.5917160.0003
Check MTime0.00180.2472160.0001
Mysql Total
Database connection0.00200.280110.0020
Mysqli_queries0.641690.3569660.0097
Looping result0.00110.1489640.0000
Template Total0.665793.820.3328
Template load0.00280.388020.0014
Template processing0.662993.362520.3315
Template load and register function0.00030.035210.0003
states
state_id_array0.00110.159410.0011
state_identifier_array0.00160.222020.0008
Override
Cache load0.00210.2943320.0001
Sytem overhead
Fetch class attribute can translate value0.00110.154820.0005
Fetch class attribute name0.00160.218860.0003
XML
Image XML parsing0.00040.059820.0002
class_abstraction
Instantiating content class attribute0.00000.002460.0000
General
dbfile0.00200.2806100.0002
String conversion0.00000.001540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs