How to remove leading and trailing spaces from a string in ColdFusion

Trim() - remove leading and trailing spaces from a string

Trim.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Trim function example: how to remove leading and trailing spaces from a string</title>
</head>

<body>
<h2 style="color:HotPink">Trim Function Example</h2>

<cfset TestString=" Test string for Trim function ">
<cfoutput>
<b>
TestString: [#TestString#]
<br />
TestString(after trim): [#Trim(TestString)#]
</b>
</cfoutput>

</body>
</html>





More ColdFusion examples