Returns the characters in a string in reverse order.
||A string or expression that evaluates to a string.
returns the characters in string
in reverse order. The string
can contain 8-bit characters or 16-bit Unicode characters. For further details on InterSystems IRIS Unicode support, refer to Unicode
in Using ObjectScript
$REVERSE does not recognize surrogate pairs. Surrogate pairs are used to represent some Chinese characters and to support the Japanese JIS2004 standard. You can use the $WISWIDE function to determine if a string contains a surrogate pair. The $WREVERSE function recognizes and correctly parses surrogate pairs. $REVERSE and $WREVERSE are otherwise identical. However, because $REVERSE is generally faster than $WREVERSE, $REVERSE is preferable for all cases where a surrogate pair is not likely to be encountered.
The following WRITE commands shows the return value from $REVERSE. The first returns “CBA”, the second returns 321.
You can use the $REVERSE function with other functions to perform search operations from the end of the string. The following example demonstrates how you can use $REVERSE with the $FIND and $LENGTH functions to locate the last example of a string within a line of text. It returns the position of that string as 33:
SET line="THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG."
WRITE "The last THE in the line begins at ",position
Content Date/Time: 2019-08-20 05:45:45