Skip to content

Latest commit

 

History

History
38 lines (31 loc) · 893 Bytes

substr.adoc

File metadata and controls

38 lines (31 loc) · 893 Bytes

substr()

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.

Table 1. Parameters

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"