Sfairadora

  • Reference Guide

find_bytes

find_bytes(bin, substr)
find_bytes(bin, pos, substr)
Finds the first occurrence of the substr data in the bin data and returns its index. If the parameter pos is specified, the data is searched from that index.
The function returns the index of the first occurrence of the data being searched. The index of the first byte is 0. If pos is negative, its value is considered 0. If the searched data is not found, an error is returned. This condition can be handled, for instance, using the try statement. If pos is beyond the end of the bin data, the function always fails (returns an error).
Note: this function serves to search binary data. To serach a string, use the analogical function find_str.

Parameters

bin
The data in which to search. The Binary type.
substr
The data to be searched. The Binary type.
pos pos
Position where begin searching. Type Int. The value 0 denotes the beginning of the data.

Return Value

The function returns the index of the first occurrence found (the Int type) or an error.

See Also