Mwnci substr() Function

Syntax

substr(string, integer, [integer])

Description

The substr() function returns a substring of a given string indicated by the starting position and the substring length.
Note the index of a string is 0. If the length requested is longer that the string, or is 0, the returned substring will default to the end of the string.

Example

a="foobar"
println(substr(a,1,2))
println("->",substr(a,3,1000),"<-")
println(substr(a,3,1))


oo
->bar<-
b

It's also possible to git a negative index which counts back a given amount of characters

a="foobar"
println(substr(a, -3))
println(substr(a, -3, 2))


bar
ba