The $LENGTH function returns the length of a string measured in characters, or in "pieces" separated by a delimiter specified by one of its arguments.
The format for the $LENGTH function is:
$L[ENGTH](expr1[,expr2])
The first expression specifies the string that $LENGTH() "measures."
The optional second expression specifies the delimiter that defines the measure; if this argument is missing, $LENGTH() returns the number of characters in the string.
If the second argument is present and not a null string, $LENGTH returns one more than the count of the number of occurrences of the second string in the first string; if the second argument is a null string, the M standard specifies that $LENGTH() returns a zero (0).
$LENGTH() provides a tool for determining the lengths of strings in two ways, characters and pieces. The two argument $LENGTH() returns the number of existing pieces, while the one argument returns the number of characters.