Skip to content
instance method

MatchData#to_a

() -> ::Array[::String?]
to_a → array

Returns the array of matches:

Example
m = /(.)(.)(\d+)(\d)/.match("THX1138.")
# => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
m.to_a # => ["HX1138", "H", "X", "113", "8"]

Related: MatchData#captures.

See also #string #to_s #size #values_at also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0