Kaya 0.5.3 reference for Prelude::substr

List of functions and data types in Prelude

String substr(String x, Int i, Int len)

Arguments

Usage

Starting at character i, return the len characters long substring. Throws an Exception if len is negative, or if i is out-of-bounds. In Kaya 0.2.4 and earlier, an Exception was also thrown if len was zero. The empty string is now returned in this case.

If the starting index is negative, then it will be counted in characters from the end of the string.

x = "abcdef";
s = substr(x,0,2); // "ab"
s = substr(x,4,1); // "e"
s = substr(x,3,10); // "def" (len truncated)
s = substr(x,-4,2); // "cd"
kaya@kayalang.org | Last modified 29 November 2011 | Supported by Durham CompSoc | Powered by Kaya