substring function

Syntax

  • string substring(inputString, startPos, endPos)

Parameters

  1. inputStringstring
  2. startPosfloat
  3. endPosfloat

Returns

Substring of inputString, extracted between indices startPos and endPos (endPos excluded).

Description

The substring function returns a substring of the inputString, starting at the index startPos and ending without the character at index endPos (endPos excluded).

Note:

The indices startPos and endPos are 0-based.

Related

Examples

substring("0123456789", 0, 5)
# result = "01234"
substring("0123456789", 2, 5)
# result = "234"
substring("0123456789", -20, 5) # startPos < 0
# result = "01234"
substring("0123456789", 0, 20)	# endPos >= len(inputString)
# result = "0123456789"
substring("0123456789", 5, 0)	# startPos >= endPos
# result = ""

In this topic