Skip to main content

substring

Returns a string that is a substring of a given string. The substring begins with the character at the specified index and extends to either the end or the specified endIndex - 1. Thus when endIndex is specified the length of the substring is endIndex - beginIndex.

substring(str, beginIndex)
# Or
substring(str, beginIndex, endIndex)

Parameters#

  • str: Target string
  • beginIndex: The beginning index, inclusive.
  • endIndex: The ending index, exclusive.

Returns#

  • The substring

Examples#

text = 'Hey, you coming for the match?'print(substring(text, indexOf(text, 'coming')))# prints, coming for the match?
text = 'Hey, you coming for the match?'print(substring(text, indexOf(text, 'coming'), indexOf(text, '?')))# prints, coming for the match