Strrchr Function

Action

Searches for the last occurrence of a character in a string.

Include file

Kernel.bdh

Syntax

Strrchr( in sString    : string,
         in nCharacter : number ): string;

Return value

String beginning with the last occurrence of the defined character. If the character is not found, the returned string is empty.

Parameter Description
sString Defines the string to search in
nCharacter Defines the character to search

Example

dcltrans
  transaction TStrrchr
  var
    sString, sResult : string;
    nChar : number;
  begin
    sString := "Hello world!";
    nChar := ord('l');
    write("string = "); write(sString); writeln;
    write("char   = "); write(chr(nChar)); writeln;

    sResult := Strrchr(sString, nChar);
    write("result = "); write(sResult); writeln;
  end TStrrchr;

Output

string = Hello world!
char   = l
result = ld!