UCE Docs / strpos

Signature

s64 strpos(String haystack, String needle, s64 offset = 0)

Parameters

haystack : string to search in
needle : substring to search for
offset : optional start offset; negative values count from the end of the string
return value : zero-based position of the first match, or -1 if needle is not found

Finds the first occurrence of needle inside haystack.

This is the closest UCE equivalent to PHP strpos(), but it returns -1 instead of false when no match is found.

If needle is an empty string, strpos() returns the normalized start offset.

Example

print(strpos("uce docs", "docs"), "\n");
Output
4