"Sputnik" help  
Sputnik Help
BinaryTrim(<binary>, <trimBinary>

Description

Removes leading and trailing occurrences of the specified binary string from the given binary string. If the optional second parameter is not provided, the function trims the default whitespace characters (0x20, 0x09, 0x0D, 0x0A). The function returns the resulting trimmed binary string.

Parameters

<binary> The input binary string to be trimmed.
<trimBinary> Optional binary string to be trimmed. If not provided, it defaults to whitespace characters (0x20, 0x09, 0x0D, 0x0A).

Return Value

Success: Returns trimmed binary string.
Failure: Returns empty binary string.

Remarks

The BinaryTrim function trims leading and trailing whitespace characters (0x20, 0x09, 0x0D, 0x0A) from the input binary string. If no additional trim string is provided, the function removes these common whitespace characters by default. This function is useful for removing unnecessary padding or whitespace from binary data, ensuring that only the relevant information remains. The resulting trimmed binary string is returned, allowing for streamlined data processing and manipulation tasks.

Related

BinaryTrimStart, BinaryTrimEnd, BinaryTrimLeft, BinaryTrimRight

Example

All possible trim types:

my $a = bin("      Hello      ");
my $b = BinaryTrim($a);
my $c = BinaryTrimStart($a);
my $d = BinaryTrimEnd($a);
say "\"$a\"";
say "\"$b\"";
say "\"$c\"";
say "\"$d\"";
// PRINTS
// "      Hello      "
// "Hello"
// "Hello      "
// "      Hello"

Using custom trim:

my $a = bin("XtXtHelloXtXt");
my $b = BinaryTrim($a, "Xt");
say "\"$a\"";
say "\"$b\"";
// PRINTS
// "XtXtHelloXtXt"
// "Hello"

 


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