Returns the characters in a string in reverse order.
||A string or expression that evaluates to a string.
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
are otherwise identical. However, because $REVERSE
is generally faster than $WREVERSE
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
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
© 1997-2019 InterSystems Corporation, Cambridge, MA