Ruby MatchData Functions
EditRocket provides the following information on MatchData functions in the Ruby source code builder.
begin(n) - Returns the offset of the start of the nth element of the match array in the string.
captures - Returns the array of captures; equivalent to mtch.to_a[1..-1].
end(n) - Returns the offset of the character immediately following the end of the nth element of the match array in the string.
inspect - Returns a string representing obj. The default to_s prints the object's class and an encoding of the object id. As a special case, the top-level object that is the initial execution context of Ruby programs returns ``main.''
length - Returns the number of elements in the match array.
new -
offset(n) - Returns a two-element array containing the beginning and ending offsets of the nth match.
post_match - Returns the portion of the original string after the current match. Equivalent to the special variable $'.
pre_match - Returns the portion of the original string before the current match. Equivalent to the special variable $`.
pretty_print(q) -
select([index]*) - Uses each index to access the matching values, returning an array of the corresponding matches.
size - Returns the number of elements in the match array.
string - Returns a frozen copy of the string passed in to match.
to_a - Returns the array of matches.
to_s - Returns the entire matched string.
values_at mtch.select([index]*) - Uses each index to access the matching values, returning an array of the corresponding matches.