substring (x, s, n)
The substring(x, s, n) function returns a substring from the parameter x. The substring includes the sth character of x and contains n characters.
If x does not contain sufficient characters, the result is truncated.
If s is negative, the substring is started at the s character from the end of the string and counts towards the end.
If n is zero or negative, the substring w returns an empty string.
This function returns a value of type Text.
Examples
substring ("This is a counting test", 4, 9)
Result: "s is a co"
substring ("This is a counting test", 4, 0)
Result: "", an empty string.
substring ("This is a counting test", 4, -5)
Result: "", an empty string.
substring ("This is a counting test", -4, 9)
Result: "test" The start position is taken from the end of the string because -4 is negative. From that position the string only contains 4 more characters, which are returned as the result.
substring ("This is a test in counting", 4, 25)
Result: "s is a test in counting" From the starting position the string only contains 23 more characters, which are returned as the result.