substring
substring(S_stringx_index[x_length] ) =>t_result/nil
Description
Creates a new substring from an input string, starting at an index point and continuing for a given length.
Creates a new substring from S_string with a starting point determined by x_index and length determined by an optional third argument x_length.
- If S_string is a symbol, the substring is taken from its print name.
- If x_length is not given, then all of the characters from x_index to the end of the string are returned.
- If x_index is negative the substring begins at the indexed character from the end of the string.
-
If x_index is out of bounds (that is, its absolute value is greater than the length of S_string),
nilis returned.
Arguments
Value Returned
|
Substring of S_string starting at the character indexed by x_index, with a maximum of x_length characters. |
|
Examples
substring("abcdef" 2 4)
=> "bcde"
substring("abcdef" 4 2)
=> "de"
substring("abcdef" -4 2)
=> "cd"
Related Topics
Return to top