INSTR() searches for a substring within a string and returns the position of the specified occurrence. The search starts from the left side of the string, and if no occurrence number is specified, it returns the position of the first occurrence. This function is useful for string manipulation, text parsing, and pattern matching.
INSTR(string, search string [, occurrence])
INSTR() returns an integer representing the position of the substring, or 0 if not found
INSTR("Green apples taste better than red apples and all other types of apples.", "apples") = 7 (first occurrence)
INSTR("Green apples taste better than red apples and all other types of apples.", "oranges") = 0 (not found)
INSTR("Green apples taste better than red apples and all other types of apples.", "apples", 1) = 7 (first occurrence)
INSTR("Green apples taste better than red apples and all other types of apples.", "apples", 2) = 36 (second occurrence)
INSTR("Green apples taste better than red apples and all other types of apples.", "apples", 3) = 66 (third occurrence)
INSTR("Green apples taste better than red apples and all other types of apples.", "apples", 4) = 0 (no fourth occurrence)
INSTR("Hello World", "o") = 5 (first 'o')
INSTR("Hello World", "o", 2) = 8 (second 'o')