Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section

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"
Copy code to clipboard

See Also