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

example.1
	substring("0123456789", 0, 5)
	# result = "01234"
example.2
	substring("0123456789", 2, 5)
	# result = "234"
example.3
	substring("0123456789", -20, 5) # startPos < 0
	# result = "01234"
example.4
	substring("0123456789", 0, 20)	# endPos >= len(<span class="cga_opparam">inputString</span>)
	# result = "0123456789"
example.5
	substring("0123456789", 5, 0)	# startPos >= endPos
	# result = ""

In this topic