Returns the position of one string within another string.
Category: | String |
Returned data type: | Integer |
INSTR(source, excerpt<, count>)
source
specifies a string to search; this can be specified as string constant, field name, or expression
excerpt
specifies a string to search for within source; this can be specified as string constant, field name, or expression
count
specifies an integer that indicates the occurrence of excerpt to search for; this can be specified as numeric constant, field name, or expression. For example, a value of 2 indicates to search for the second occurrence of excerpt in source
The INSTR function searches source from left to right for the count-th occurrence of excerpt. If excerpt is not found in source, the function returns a value of 0.
source = "This is a simple sentence."
excerpt = "is"
position = instr(source, excerpt, 1) // outputs 3
position = instr(source, excerpt, 2) // outputs 6