R-INDEX function
- Last Updated: February 11, 2026
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
Returns an INTEGER value that indicates the position of the target string within the source string. In contrast to the INDEX function, R-INDEX performs the search from right to left.
Syntax
|
- source
- A constant, field name, variable name, or expression that results in a CHARACTER or LONGCHAR value.
- target
- A CHARACTER or LONGCHAR expression whose position you want to
locate in source. If target does
not exist within source, R-INDEX returns 0.
If a starting parameter is not specified, then the search for the target pattern begins at the right-most character. Even though the search is started from the right, the target position is calculated from the left. For example, this code returns a 3 rather than a 2:
R-INDEX("abcd" , "c") - starting
- An integer that specifies the begin point for the search. The search is right-to-left and starts from the starting point. For example, this statement returns 1 R-INDEX("abcdefabcdef","abc",6).
Examples
This procedure prompts you to enter a character string and a pattern to match against the string. It then displays the starting position of the string where the pattern was found.
r-rindex.p
|
This example also uses a starting value:
r-rndex.p
|
Notes
- If either operand is case sensitive, then the R-INDEX function is also case sensitive.
- If either the source string or target pattern is null, the result is 0.
- The R-INDEX function is double-byte enabled. You can specify target and source strings for the R-INDEX function that contain double-byte characters.