Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing Whitespace

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Does anyone know a CF tag that can remove all spaces from a line of text. For example...I have a value called "Bonita Bay" and I want to create a variable called "BonitaBay". How do i remove the space? Trim() does not work and RemoveChars will not work because I will not always know the position of the spaces . Any help is greatly appreciated.
 
replace
Description: Returns string with occurrences of substring1 replaced with substring2 in a specified scope.

Syntax: replace(string, substring1, substring2 [, scope ])


substring1 = String to replace

substring2 = String that replaces occurrences of substring1

scope:
Defines how to complete the replace operation:
ONE replace only the first occurrence (default)
ALL replace all occurrences
Sylvano
dsylvano@hotmail.com

"every and each day when I learn something new is a small victory..."
 
Yes, so according to WWebSpider, the replace() function would work for what you want:

<CFSET myString = &quot;Bonita Bay&quot;>

<CFOUTPUT>
#Replace(myString, &quot; &quot;, &quot;&quot;, &quot;ALL&quot;)#
</CFOUTPUT>

or using the Char() function you can do it this way

<CFOUTPUT>
#Replace(myString, Chr(32), Chr(0), &quot;ALL&quot;)#
</CFOUTPUT> - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top