substring

Returns the substring of the text from the start index (inclusive) to the end index (optional and exclusive).
Accepts
Returns
Syntax
substring(text, startIndex, endIndex?) text.substring(startIndex, endIndex?)

If only the start index is entered, the text up to and including that character is removed and the remaining text is returned. Think of the following as "I'm removing the first 3 characters".

substring("bensomething", 3)
=
something "something"

If both the start and end indexes are entered, the characters after the start index and up to and including the end index are returned. Think of the following as "I'm keeping the 4th to the 7th characters".

substring("bensomething", 3, 7)
=
some "some"

You can also use negative numbers to change how the splitting of text is handled. If a negative start index is entered, that number of characters starting from the end of the text will be returned. Think of the following as "I'm keeping the last 5 characters".

substring("bensomething", -5)
=
thing "thing"

If a negative end index is entered, the characters after the start index will be returned and then the number of characters in the end index will be removed from the end of the text. Think of the following as "I'm keeping everything from the 4th character onwards, and then removing the last 5 characters."

substring("bensomething", 3, -5)
=
some "some"

Adding a negative start index with an end index will return nothing.