Clib Get Substring Method
The Clib Get Substring method searches a string for the first occurrence of a string. It returns one of the following values:
If it finds the string that you specify in the findString argument, then it returns the string that:
Begins at the first occurrence of the value that you specify in the findString argument.
Ends at the end of the string that you specify in the sourceString argument.
If it does not find the string that you specify in the findString argument, then it returns the following value:
Null
It searches the string that you specify in the sourceString argument from the beginning of this string.
It is recommended that use the Clib Get Substring method only if you cannot use the equivalent standard JavaScript method.
Format
Clib.strstr(sourceString, findString)
Clib.strstri(sourceString, findString)
You can use one of the following:
Search that is case-sensitive. You use Clib.strstr.
Search that is not case-sensitive. You use Clib.strstri.
The following table describes the arguments for the Clib Get Substring method.
Argument | Description |
---|---|
sourceString |
The string that this method searches. |
findString |
The string that this method must find. |
Example 1
The following example uses Clib.strstr:
function Test1_Click ()
{
var str = "We have to go to Haverford."
var substr = Clib.strstr(str, 'H');
TheApplication().RaiseErrorText("str = " + str + "\nsubstr = " +substr);
}
This example provides the following result:
str = We have to go to Haverford
substr = Haverford
The following example uses Clib.strstri:
function Test_Click ()
{
var str = "We have to go to Haverford."
var substr = Clib.strstri(str, 'H');
TheApplication().RaiseErrorText("str = " + str + "\nsubstr = " +substr);
}
This example provides the following result:
str = We have to go to Haverford.
substr = have to go to Haverford.
For more information, see Create String From Substring Method.