Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method · added in Ruby 3.2
MatchData#deconstruct
() -> ::Array[::String?]
deconstruct
re.c
View on GitHub ↗
static VALUE
match_captures(VALUE match)
{
return match_array(match, 1);
}
Alias of #captures
Returns the array of captures, which are all matches except m[0]:
Example
m = /(.)(.)(\d+)(\d)/.match("THX1138.") # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8"> m[0] # => "HX1138" m.captures # => ["H", "X", "113", "8"]
Related: MatchData.to_a.
Ruby version changes
-
3.2
-
MatchData#deconstructhas been added. [Feature #18821]
-