| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Locates the position of a substring within a character string.
RAt( <cSearch>, <cString>, [<nStart>], [<nEnd>] ) --> nPos
The function returns a numeric value which is the position in <cString> where <cSubString> is found. The return value is zero when <cSubString> is not found.
This function RAt() searches the string <cString> from right to left for the character string <cSearch>. The search begins at position <nStart> and is case-sensitive. If <cString> does not contain <cSearch>, the function returns 0.
Note: use function At() to search <cString> from left to right.
| See also: | $, At(), IN, Left(), Right(), StrTran(), SubStr() |
| Category: | Character functions |
| Source: | rtl\rat.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example demonstrates various results of RAt().
PROCEDURE Main()
LOCAL cString := "xHarbour"
? RAt( "Ha", cString ) // result: 2
? RAt( "ARB" , cString ) // result: 0
? RAt( "ARB" , Upper(cString) ) // result: 3
? RAt( "r" , cString ) // result: 8
? RAt( "r" , cString, 7 ) // result: 4
? RAt( "r" , cString, 5, 7 ) // result: 0
RETURN
http://www.xHarbour.com