User Tools

Site Tools


en:instr

This is an old revision of the document!


Instr (Function)

Format

instr ( haystack_expr , needle_expr )
instr ( haystack_expr , needle_expr , start_expr )
instr ( haystack_expr , needle_expr , start_expr , boolean_expression)

returns integer_expression

Description

Check to see if the string needle_expr is contained in the string haystack_expr. If it is, then this function will return the index of starting character of the first place where needle_expr occurs. Otherwise, this function will return 0.

You may optionally specify a starting location for the search to begin start_expr. If the start is 1 or greater the search will begin from the specified character from the start. If the start is < 0 then the search will begin from the nth character from the end. The search will ALWAYS look forward.

An optional boolean_expression may be used to specify that the search will treat upper and lower case letters the same.

Note

String indices begin at 1.

Example

print instr("Hello", "lo")
print instr("101,222,333",",",5)

will display

4
8

See Also

History

0.9.6.55New to Version
1.99.99.53Added start position < 0
en/instr.1471027900.txt.gz · Last modified: 2020/02/28 10:46 (external edit)