lang • instr

InStr

Position = InStr ( String AS String , Substring AS String [ , Start AS Integer , Comparison AS Integer ] )

Returns the position of the first occurrence of Substring in String.

Start specifies where to start the search:

  • If Start is omitted, or if Start is 0, the search begins at the beginning of the string.

  • If Start is > 0, the search begins at the position Start.

  • If Start is < 0, the search begins at the position (- Start) from the end of the string.

Since 3.4
Comparison can be one of the following value:

If the substring is not found, this function returns zero.

This function only deal with ASCII strings. To manipulate UTF-8 strings, use the String class.

Examples

Print InStr("Gambas is basic", "bas")
4
Print InStr("Gambas is basic", "bas", 5)
11
Print InStr("Gambas is basic", "not")
0

See also