Type:
Class

MatchData is the type of the special variable $~, and is the type of the object returned by Regexp#match and Regexp.last_match. It encapsulates all the results of a pattern match, results normally accessed through the special variables $&, $', $`, $1, $2, and so on.

length
  • References/Ruby on Rails/Ruby/Classes/MatchData

mtch.length â integer Instance Public methods Returns the number of elements

2025-01-10 15:47:30
post_match
  • References/Ruby on Rails/Ruby/Classes/MatchData

mtch.post_match â str Instance Public methods Returns the portion of the

2025-01-10 15:47:30
size
  • References/Ruby on Rails/Ruby/Classes/MatchData

mtch.size â integer Instance Public methods Returns the number of elements

2025-01-10 15:47:30
offset
  • References/Ruby on Rails/Ruby/Classes/MatchData

mtch.offset(n) â array Instance Public methods Returns a two-element array

2025-01-10 15:47:30
[]
  • References/Ruby on Rails/Ruby/Classes/MatchData

mtch[i] â str or nilmtch[start, length] â arraymtch[range] â arraymtch[name] â str or nil

2025-01-10 15:47:30
regexp
  • References/Ruby on Rails/Ruby/Classes/MatchData

mtch.regexp â regexp Instance Public methods Returns the regexp.

2025-01-10 15:47:30
names
  • References/Ruby on Rails/Ruby/Classes/MatchData

mtch.names â [name1, name2, ...] Instance Public methods Returns a list of

2025-01-10 15:47:30
end
  • References/Ruby on Rails/Ruby/Classes/MatchData

mtch.end(n) â integer Instance Public methods Returns the offset of the character

2025-01-10 15:47:30
to_a
  • References/Ruby on Rails/Ruby/Classes/MatchData

mtch.to_a â anArray Instance Public methods Returns the array of matches

2025-01-10 15:47:30
string
  • References/Ruby on Rails/Ruby/Classes/MatchData

mtch.string â str Instance Public methods Returns a frozen copy of the string

2025-01-10 15:47:30