"Sputnik" help  
Sputnik Help
BinaryIndexOf(<binary>,<needle>,[<ignoreCase>],[<start>],[<length>])

Description

The BinaryIndexOf function is used to search for the first occurrence of a needle within a binary string. It returns the index of the found needle, or -1 if the needle is not found.

Parameters

<binary> The binary string in which to search for the needle.
<needle> The value to search for. It can be either a byte or a binary string.
<ignoreCase> Optional boolean value indicating whether the search should be case-insensitive. (Default: false)
<start> Optional starting index of the search within the binary string. (Default: 0)
<length> Optional maximum length of the search within the binary string. (Default: Full size)

Return Value

Success: Returns the index of the first occurrence of the needle within the binary string..
Failure: Returns -1.

Remarks

The BinaryIndexOf function performs a search for the needle within the binary string. If the needle is a byte, the function searches for the byte value within the binary string. If the needle is a binary string, the function searches for the exact binary sequence within the binary string. The search can be case-insensitive by setting the <ignoreCase> parameter to true. The <start> parameter determines the starting index of the search, and the <length> parameter limits the search to a specific length within the binary string. By default, the entire binary string is searched. The <useLength> parameter controls whether the <length> parameter should be used.

Related

BinaryContains

Example

Example of usage:

my $a = Bin("Hello World!");
say BinaryIndexOf($a, "Wo");
say BinaryIndexOf($a, "Cat");

// PRINTS
// 6
// -1

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org