Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

RIGHT

Returns a specified number of characters from the right end of a string.

Synopsis

RIGHT(string,length)

Arguments

string An expression that resolves to a string from which the rightmost characters are returned.
length An expression that resolves to a positive integer indicating how many characters to return. If 0, a zero-length string ("") is returned. Fractional numbers are truncated to an integer. If greater than or equal to the number of characters in string, the entire string is returned. No padding is performed.

Description

The RIGHT function returns the specified number of characters counting backwards from the end (right end) of a string. If you specify a length greater than the string length, the entire string is returned. To determine the number of characters in string, use the LEN function.

The LEFT function returns the specified number of characters from the beginning (left end) of a string.

Examples

The following example uses the RIGHT function to return a specified number of characters from the right side of a string:

AnyString = "Hello World"
PRINT RIGHT(AnyString,1);    ! Returns "d"
PRINT RIGHT(AnyString,5);    ! Returns "World"
PRINT RIGHT(AnyString,20);   ! Returns "Hello World"

See Also

Feedback