Handlebar Helper Function: Substring

Extracts a portion of a string starting from a specified position. The function can extract either the remainder of the string from the start position or a specific length of characters.

ParameterTypeDescription
subjectstringRequired. The string to extract from. Must be a string or convertible to a string.
startnumber or stringRequired. The starting position for extraction. The first character is at position 1. Must be a number or convertible to a number. The minimum value is 1.
lengthnumber or stringThe number of characters to extract. Must be a number or convertible to a number, and must be a positive value.

The function returns a substring of the input string.

If you don’t specify the length parameter, the function returns the remainder of the string from the start position. If the start position is a number that’s greater than the number of characters in the string, it returns an empty string. If the value of the length parameter is larger than the number of characters remaining in the string or is less than 0, the function returns all characters from the start position to the end of the string. If the value of the subject parameter is null, the function returns an empty string.