class String
def at(position)
str.at("lo") # => "lo"
str.at(/ol/) # => nil
str.at(/lo/) # => "lo"
str = "hello"
the string. In both cases, +nil+ is returned if there is no match.
If a String is given, that given string is returned if it occurs in
If a Regexp is given, the matching portion of the string is returned.
str.at(5..-1) # => ""
str.at(5) # => nil
str.at(-2..-1) # => "lo"
str.at(-2) # => "l"
str.at(1..3) # => "ell"
str.at(0) # => "h"
str = "hello"
the beginning of the range is greater than the end of the string.
if the initial offset falls outside the string. Returns an empty string if
offset is negative, it is counted from the end of the string. Returns +nil+
characters at offsets given by the range is returned. In both cases, if an
position 1, and so on. If a range is supplied, a substring containing
position. The first character of the string is at position 0, the next at
If you pass a single integer, returns a substring of one character at that
def at(position) self[position] end