eql?

mtch == mtch2 â true or false Instance Public methods EqualityâTwo matchdata are equal if their target strings, patterns, and matched positions are identical.

hash

mtch.hash â integer Instance Public methods Produce a hash based on the target string, regexp and matched positions of this matchdata.

inspect

mtch.inspect â str Instance Public methods Returns a printable version of mtch. puts /.$/.match("foo").inspect #=> #<MatchData "o"> puts /(.)(.)(.)/.match("foo").inspect #=> #<MatchData "foo" 1:"f" 2:"o" 3:"o"> puts /(.)(.)?(.)/.match("fo").inspect #=> #<MatchData "fo" 1:"f" 2:nil 3:"o"> puts /(?<foo>.)(?<bar>.)(?<baz>.)/.match("hoge").inspect #=> #<MatchData "hog" foo:"h" bar:"o" baz:"g">

length

mtch.length â integer Instance Public methods Returns the number of elements in the match array. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.length #=> 5 m.size #=> 5

names

mtch.names â [name1, name2, ...] Instance Public methods Returns a list of names of captures as an array of strings. It is same as mtch.regexp.names. /(?<foo>.)(?<bar>.)(?<baz>.)/.match("hoge").names #=> ["foo", "bar", "baz"] m = /(?<x>.)(?<y>.)?/.match("a") #=> #<MatchData "a" x:"a" y:nil> m.names #=> ["x", "y"]

offset

mtch.offset(n) â array Instance Public methods Returns a two-element array containing the beginning and ending offsets of the nth match. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.offset(0) #=> [1, 7] m.offset(4) #=> [6, 7] m = /(?<foo>.)(.)(?<bar>.)/.match("hoge") p m.offset(:foo) #=> [0, 1] p m.offset(:bar) #=> [2, 3]

post_match

mtch.post_match â str Instance Public methods Returns the portion of the original string after the current match. Equivalent to the special variable $'. m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") m.post_match #=> ": The Movie"

pre_match

mtch.pre_match â str Instance Public methods Returns the portion of the original string before the current match. Equivalent to the special variable $`. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.pre_match #=> "T"

pretty_print

pretty_print(q) Instance Public methods

regexp

mtch.regexp â regexp Instance Public methods Returns the regexp. m = /a.*b/.match("abc") m.regexp #=> /a.*b/