Left(string, count)

Description

Returns the count of characters from the beginning of a string argument.

Category

String functions

See also

Right, Mid, Len

Parameters

Parameter
Description
string
String from which the leftmost characters are retrieved
count
Positive integer; number of characters to return

Example

<!--- This example shows the use of Left --->
<html>
<head>
<title>Left Example</title>
</head>

<body bgcolor = silver>
<H3>Left Example</H3>

<cfif IsDefined("Form.MyText")>
<!--- if len is 0, then err --->
    <cfif Len(FORM.myText) is not 0>
        <cfif Len(FORM.myText) LTE FORM.RemoveChars>
        <P>Your string <cfoutput>#FORM.myText#</cfoutput>
        only has <cfoutput>#Len(FORM.myText)#</cfoutput>
        characters. You cannot output the <cfoutput>#FORM.removeChars#
         </cfoutput>
        leftmost characters of this string because it is not long enough.
        <cfelse>
        <P>Your original string: <cfoutput>#FORM.myText#</cfoutput>
        <P>Your changed string, showing only the
         <cfoutput>#FORM.removeChars#</cfoutput> leftmost characters:
        <cfoutput>#Left(Form.myText, FORM.removeChars)#
        </cfoutput>
        </cfif>
    <cfelse>
    <P>Please enter a string
    </cfif>
</cfif>
...