View comments | RSS feed

Trim

Description

Removes leading and trailing spaces from a string.

Return value

A copy of string, after removing leading and trailing spaces.

Category

String functions

Syntax

Trim(string)

See also

LTrim, RTrim

Parameters

Parameter Description
string
A string or a variable that contains one

Example

<h3>Trim Example</h3>
<cfif IsDefined("FORM.myText")>
  <cfoutput>
    <pre>
      Your string:  "#FORM.myText#"
      Your string:  "#trim(FORM.myText)#"
      (trimmed on both sides)
    </pre>
  </cfoutput>
</cfif>
<form action = "trim.cfm">
<p>Type in some text, and it will be modified by trim to remove leading 
spaces from the left and right
<p><input type = "Text" name = "myText" value = "   TEST   ">
<p><input type = "Submit" name = "">
</form>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


No screen name said on Aug 8, 2003 at 1:46 AM :
i have just a small comment to make is that on the trim exemple for cfml reference on my coldfusion mx the sample code it's missing a method="post" on the form <action="trim.cfm">

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt2109.htm