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


Checks if a binary string contains a specified needle and returns a boolean result.


<length> The binary string to search within.
<needle> The binary substring or byte (if numeric value is given) to search for.
<ignoreCase> Optional whether the search should be case-insensitive. (Default: false)
<start> Optional index in the binary string to start the search from.. (Default: 0)

Optional maximum number of characters to search. (Default: The entire length of the binary string)

Return Value

Success: Returns true if the needle is found within the binary string.
Failure: Returns false.


If the needle is a numeric value, it is treated as a byte to search for within the binary string.
If ignoreCase is set to true, the search is performed in a case-insensitive manner.
The start parameter specifies the index to start the search from in the binary string. If start is negative, the search starts from the end of the binary string.
The length parameter limits the number of characters to search. If length is negative, the search is performed backward from the starting index.

The comparison is performed based on the ASCII character mapping. The function checks whether the binary string contains the needle string. By default, the comparison is case-sensitive, meaning that the function distinguishes between uppercase and lowercase characters. To perform a case-insensitive comparison, set the ignoreCase parameter to true.




Example using all types of params:

my $binary = (Binary)"Hello World";
my $substring = (Binary)"lo";
say BinaryContains($binary, $substring);
say BinaryContains($binary, (Binary)"abc");
say BinaryContains($binary, (Binary)"LO", true);
say BinaryContains($binary, 111);
say BinaryContains($binary, (Binary)"World", false, 6);
// true
// false
// true
// true
// true


Cheryl (uberfox@hotmail.com)