Clib Get Last Substring Method
The Clib Get Last Substring method searches a string for the last occurrence of a character. It returns one of the following values:
If it finds the character, then it returns a string that includes the following items:
Begins at the rightmost occurrence of the value that you specify in the char argument
Ends with the rightmost character of the string that you specify in the string argument
If it does not find the character, then it returns the following value:
Null
It is recommended that you use the Clib Get Last Substring method only if you cannot use the equivalent standard JavaScript method.
Format
Clib.strrchr(string, char)
The following table describes the arguments for the Clib Get Last Substring method.
Argument | Description |
---|---|
string |
A string literal or string variable that contains the character that this method searches. |
char |
The character that this method searches for. |
Example
The following example uses the Clib Get Last Substring method:
var str = "I don’t like soggy cereal."
var substr = Clib.strrchr(str, 'o');
TheApplication().RaiseErrorText("str = " + str + "\nsubstr = " + substr);
This example provides the following result:
str = I don’t like soggy cereal.
substr = oggy cereal.
For more information, see Create String From Substring Method.