INSTR

Finds the first occurrence of a substring within a string.

This function corresponds to the instr(X, Y) function in SQLite. It searches for the first occurrence of string Y within string X and returns the 1-based index of the beginning of Y. If Y is not found within X, it returns 0.

The search is case-sensitive by default, but this can be influenced by the case_sensitive_like pragma. If either X or Y is NULL, the result is NULL.

Example

// SELECT instr('SQLite is fun', 'fun') -> 12
// SELECT instr(productName, 'Apple') FROM Products
val position = select(INSTR(Products.productName, StringLiteral("Apple"))).from(Products)

Return

A KQLiteColumn of type Long containing the 1-based starting position of the substring, or 0 if the substring is not found.

Author

MOHAMMAD AZIM ANSARI

Parameters

x

The string or column to be searched (the "haystack").

y

The substring or column to search for (the "needle").

See also