Vicon Shogun banner

Description

Searches a string in reverse order for a character.

Because Shogun Post does not have a character data type, a string is used. If character string is empty, the command will fail. If the character string is longer than one character, only the first character will be used in the reverse search.

Functional area

String

Command syntax

Syntax

strReverseFind "string" "findChar"

Arguments

NameTypeRequiredComments
stringstringyesString to search in.
charstringyesString of length 1, which will be searched for in string.

Flags

None

Return value

integer

Returns the zero-based index of the last occurrence a character in a string.

Examples

// Search for a character in reverse order. Extract
// the string after the character.
string $str = "This is some text";
string $subStr;
int $index, $length;

// Search in reverse for a space
$index = `strReverseFind $str " "`;
print $index;
// Should be 12

// Get the remainder of the string after that.
$length = `strLength $str`;
$index = $length - $index - 1;
$subStr = `strRight $str $index`;
print $subStr;
// Should be "text"

Additional information

Related commands