Important
|
Deprecated in 5.0. Replaced with method substring() of the string instance. |
substr(string, n, len) => void
Extracts the substring from string that begins at the nth character and is of length len.
string |
String |
Source string. |
n |
Integer |
Starting character index for substring. The n must be a positive whole number. If n is greater than length(string), then empty string is returned. |
len |
Integer |
Length of substring. If you omit length, the rest of the string is returned. Optional parameter. |
Return
Extracted substring.
Example
print(substr("abcdef", 3, 2)); //Will print: "cd" print(substr("abcdef", 8)); //Will print: "" print(substr("abcdef", 4)); //Will print: "def"