String.substr

String.substr

String.substr

Function

Truncate the string by length starting from the specified position.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
startIntNo0Starting character position; a negative number means counting backwards from the end.
lengthIntNoString lengthTruncation length; negative numbers are treated as 0.

Return value

TypeDescription
StringReturns the new string after interception.

Example

Notes

  • Unlike the second parameter of slice, the second parameter of substr represents the length.