Find string in binary data

Syntax

int findb(string substring [len] [from])

 

Parameters

string - string to search in. Must be str variable.

substring - substring to find. Can be string or pointer to binary data.

len - number of bytes in substring. Default: if substring is string - substring length, otherwise this parameter is required.

from - 0-based character index, from which to start search. Default 0.

 

Remarks

Returns 0-based index of first character of substring in string. If not found, returns -1. Both strings can contain binary data (null characters).

 

Example

str s="one two"; s[3]=0
 now s contains null character at position 3
int i=findb(s "e[0]t" 3)
 now i is 2