Right
825
Right
Description
Gets a specified number of characters from a string, beginning at the right.
Returns the specified number of characters from the end (or
right
side) of the specified string.
Returns
•
If the length of the string is greater than or equal to
count
, the rightmost
count
characters of
the string
•
If
count
is greater than the length of the string, the whole string
•
If
count
is greater than 1, and the string is empty, an empty string
Category
String functions
Function syntax
Right
(
string, count
)
See also
Left
,
Mid
,
Reverse
Parameters
Example
<!--- Simple Right Example--->
<cfoutput>
#Right("See the quick red fox jump over the fence", 9)#
<br>
#Right("ColdFusion", 6)#
</cfoutput>
<!--- Right Example using form input --->
<h3>Right Example</h3>
<cfif IsDefined("Form.MyText")>
<!--- If len returns 0 (zero), then show error message. --->
<cfif Len(FORM.myText)>
<cfif Len(FORM.myText) LTE FORM.RemoveChars>
<cfoutput><p style="color: red; font-weight: bold">Your string
#FORM.myText# only has #Len(FORM.myText)# characters. You cannot output
the #FORM.removeChars# rightmost characters of this string because it
is not long enough.</p></cfoutput>
<cfelse>
<cfoutput><p>Your original string: <strong>#FORM.myText#</strong>
<p>Your changed string, showing only the <strong>#FORM.removeChars#
</strong> rightmost characters:
<strong>#right(Form.myText, FORM.removeChars)#</strong></p>
Parameter
Description
string
A string or a variable that contains one.
count
A positive integer that specifies the number of characters to return.
Summary of Contents for COLFUSION MX 7 - INSTALLING AND USING COLDFUSION MX
Page 1: ...COLDFUSION MX7 CFML Reference...
Page 20: ...20 Chapter 1 Reserved Words and Variables...
Page 50: ...50 Chapter 2 ColdFusion Tags cfelse br Searching cfif cfloop cfif...
Page 101: ...cfdefaultcase 101 cfdefaultcase cfswitch cfoutput Your grade is grade cfoutput...
Page 115: ...cfdocumentsection 115 cfdocumentsection cfoutput cfdocument...
Page 411: ...cftable 411 cftable body html...
Page 515: ...Chr 515 maxlength 5 p input type Submit name input type RESET cfform...
Page 605: ...GetEncoding 605 WriteOutput The encoding is theEncoding cfscript cfif...
Page 629: ...GetProfileString 629 tr td input type Submit name Submit value Submit td td td tr table form...
Page 655: ...IIf 655 cfoutput IIf Hour Now GTE 12 DE It is afternoon or evening DE It is morning cfoutput b...
Page 664: ...664 Chapter 3 ColdFusion Functions cfelse h3 Conversion error h3 cfif...
Page 687: ...IsStruct 687 cfoutput cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Page 751: ...LSDateFormat 751 hr noshade cfoutput cfloop...
Page 861: ...StructFind 861 cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Page 903: ...Val 903 value Is the beginning numeric name form...
Page 932: ...932 Chapter 3 ColdFusion Functions...
Page 944: ...944 Chapter 4 ColdFusion MX Flash Form Style Reference...
Page 962: ...962 Chapter 5 Application CFC Reference...
Page 1054: ...1054 Chapter 6 ColdFusion MX Event Gateway Reference...