Main Index : Reference :
[int] memmem([bytes] mem,[bytes] phrase)[int] memmem([bytes] mem,[bytes] phrase,[int] pos)
mem is the byte array.phrase is the search phrase.pos is the optional start position of the search.
memmem() returns the position of the first occurence of phrase within the byte array mem. If the third parameter is passed, only the part of mem that is after the position pos is searched. If no match is found, the return value is -1.
Remember: The first element of a byte array is at position 0.
// See also the examples for strstr().
// Locates and extracts an element in a data file.
var file = loadDataFile();
var signature = getElementSignature();
var length = getElementLength();
var pos = memmem(file,signature);
var element = memmid(file,pos,length);