Instr
Function Instr( [start,] String1, String2 [,CaseInsensitive] )
Returns an integer specifying the start of String2 in String1.
Syntax x = Instr( "Hello There", "There" )
Remarks
Instr returns an integer value indicating where String2 appears in String1.
If the optional start parameter is supplied, the search will begin at the startth position in String1.
Even if the start parameter is supplied the offset returned by Instr will be referenced from the beginning of String1.
Instr is case-insensitive (internally compares uppercase versions) by default.
If you wish Instr to be case sensitive, supply an expression that reduces to non-zero (true) in the optional CaseInsensitive parameter.
See Also:
Left Mid Right String Functions
Example Script
NUMBER x = 0
STRING s1 = "Hello There",s2 = "tHeRe"
x = INSTR(1,s1,s2,1) ' x will be set to 0 (case sensitive compare)
PRINT x
x = INSTR(s1,s2,1) ' x will be set to 0 (case sensitive compare)
PRINT x
x = INSTR(1,s1,s2) ' x will be set to 7
PRINT x
x = INSTR(4,s1,s2) ' x will be set to 7
PRINT x
x = INSTR(s1,s2) ' x will be set to 7
PRINT x
x = INSTR(s1,s2,0) ' x will be set to 7
PRINT x
x = INSTR(1,s1,s2,0) ' x will be set to 7
PRINT x
Script Output
0
0
7
7
7
7
7