<cfoutput>
<cfset str ="hai how are you? i am fine
what about you?" >
<cfdump var="#str#" /><br>
<cfset str = #replace(str,"#chr(13)&chr(10)#"," ","all")#>
<cfdump var="#str#" /><br>
<cfset str = #reReplace(str, "#chr(13)&chr(10)#"," ")#>
<cfdump var="#str#" />
</cfoutput>
Above code produce the this kind of output
hai how are you? i am fine what about you?
hai how are you? i am fine what about you?
hai how are you? i am fine what about you?
my task is replace the new line character but i can't. if any way to do that please let me know?
I can understand your issue but we cannot produce a newline character by cfset. And #chr(13) & chr(10)# is not valid. it should be either chr(13) or chr(10). You can do two replaces one by one. And ReReplace function is used to replace string based on a RegEx. You can use replaceNoCase here. Here is my sample code.
<cfif isDefined("form.submit")>
<cfset str =form.TestField>
<cfoutput>
#findNoCase(Chr(13), str)# <!--- It is available --->
<cfset str = replaceNoCase(str, chr(13), ' ','All')>
<cfset str = replaceNoCase(str, chr(10), ' ','All')>
<cfdump var="#str#"><!--- string after replacement --->
</cfoutput>
</cfif>
<form name="test" method="post">
<textarea name="TestField"></textarea>
<input type="submit"name="submit" value="submit">
</form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With