trim
Description
Removes leading and trailing spaces and control characters from a string.
Categories
Related
Syntax
Trim(string)
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| string | A string or a variable that contains a string. |
Returns
A copy
of the string parameter, after removing leading and trailing
spaces and control characters.
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 method = "post" action = "trim.cfm">
Type in some text, and it will be modified by trim to remove leading
spaces from the left and right
<input type = "Text" name = "myText" value = " TEST ">
<input type = "Submit" name = "">
</form>