InStr function (LotusScript® Language)
Returns the position of the character that begins the first occurrence of one string within another string.
Syntax
InStr ( [ begin , ] string1 , string2 )
or
InStr ( [ begin , ] string1 , string2 [, compMethod ] )
Elements
begin
Optional. A numeric expression with a positive integer value. begin specifies the character position in string1 where InStr should begin searching for string2. If you omit begin, it defaults to 1. If you specify compMethod, you must specify begin as well.
string1
The string that InStr searches for the occurrence of string2.
string2
The string for which InStr searches to see if it occurs in string1.
compMethod
A number designating the comparison method:
Number |
Comparison method |
---|---|
0 |
case-sensitive, pitch-sensitive |
1 |
case-insensitive, pitch-sensitive |
4 |
case-sensitive, pitch-insensitive |
5 |
case-insensitive, pitch-insensitive |
If you specify compMethod, you must specify begin as well.
If you omit compMethod, the default comparison mode is the mode set by the Option Compare statement for this module. If there is no statement for the module, the default is case-sensitive and pitch-sensitive.
Return value
InStr returns the character position of the first occurrence of string2 within string1. The following table shows how the function responds to various conditions.
Condition |
Return value |
---|---|
string1 is the empty string ("") |
0 |
string2 is not found after begin in string1 |
0 |
begin is larger than the length of string1 |
0 |
string2 is the empty string ("") |
The value of begin. If you omit begin, InStr returns the value 1. |
string1 is NULL |
NULL |
string2 is NULL |
NULL |
begin or compMethod is NULL |
Error |
Usage
If you want to work with bytes, use the InStrB function.