substr(text, number, number)

substr(text, number, number), function

def const pure substr(source: text, start: number, count: number): text

Returns a sub-value from a source text, a starting position and a length.

Examples

source = "Hello World!"
show summary "" with
  substr(source, 0, 3) // returns "Hel"
  substr(source, -3, 2) // returns "ld"
  substr(source, 6, 100) // returns "World!"
  substr(source, 100, 257) // returns ""
  substr(source, 2, -1) // returns ""

Remark

If the targeted segment of characters is partially or completly outside the text value, then the segment is clipped to fit (as illustrated hereinabove).

If count is negative, the function will return an empty text (as illustrated hereinabove).

See also

User Contributed Notes
0 notes + add a note