Cicode Programming Reference > Cicode Function Categories > String Functions Introduction > StrSearch

StrSearch

Searches for a string within a string, commencing at a specified offset. The result of the search is the index in the source string, where the first character of the sub-string is found. Index 0 is the first character in the string, index 1 is the second, and so on.

Syntax

StrSearch(Offset, String, Substring)

Offset:

The offset in the string, commencing at 0.

String:

The source string.

Substring:

The substring to search for.

Return Value

The index in the search string, or -1 if the sub-string does not exist in the string.

Related Functions

StrLength

Example

Variable=StrSearch(1,"ABCDEF","CD");
! Sets Variable to 2.
Variable=StrSearch(4,"ABCDEF","CD");
! Sets Variable to -1.
Variable=StrSearch(5,"ABCDEF","F");
! Sets Variable to 5.

See Also

String Functions