Product Site

5.1.7.22. []

If length is omitted, returns the character at position n of the receiving string. If n is larger than the length of the receiving string, a null string is returned.

If length is specified, returns the substring of the receiving string starting at position n and of length length. No padding occurs for any portion of the returned string not within the boundaries of the receiving string.

The n must be a positive whole number, and, if specified, length must be a non-negative whole number.

See also methods subChar and substr.

Example 5.59. String class — [] method
Say "abc"[2]       -- "b"
Say "abc"[2,4]     -- "bc"