Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
proc
/
self
/
root
/
proc
/
self
/
root
/
opt
/
ruby-2.6
/
usr
/
share
/
ri
/
2.6.0
/
system
/
MatchData
/
//proc/self/root/proc/self/root/opt/ruby-2.6/usr/share/ri/2.6.0/system/MatchData/cdesc-MatchData.ri
U:RDoc::NormalClass[iI"MatchData:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[ I"Q<code>MatchData</code> encapsulates the result of matching a Regexp against ;TI"0string. It is returned by Regexp#match and ;TI"DString#match, and also stored in a global variable returned by ;TI"Regexp.last_match.;To:RDoc::Markup::BlankLine o; ;[I"Usage:;T@o:RDoc::Markup::Verbatim;[I"@url = 'https://docs.ruby-lang.org/en/2.5.0/MatchData.html' ;TI"Am = url.match(/(\d\.?)+/) # => #<MatchData "2.5.0" 1:"0"> ;TI"[m.string # => "https://docs.ruby-lang.org/en/2.5.0/MatchData.html" ;TI"1m.regexp # => /(\d\.?)+/ ;TI"!# entire matched substring: ;TI".m[0] # => "2.5.0" ;TI" ;TI"%# Working with unnamed captures ;TI"/m = url.match(%r{([^/]+)/([^/]+)\.html$}) ;TI"=m.captures # => ["2.5.0", "MatchData"] ;TI".m[1] # => "2.5.0" ;TI"=m.values_at(1, 2) # => ["2.5.0", "MatchData"] ;TI" ;TI"## Working with named captures ;TI"Bm = url.match(%r{(?<version>[^/]+)/(?<module>[^/]+)\.html$}) ;TI"=m.captures # => ["2.5.0", "MatchData"] ;TI"Rm.named_captures # => {"version"=>"2.5.0", "module"=>"MatchData"} ;TI".m[:version] # => "2.5.0" ;TI"$m.values_at(:version, :module) ;TI"= # => ["2.5.0", "MatchData"] ;TI"*# Numerical indexes are working, too ;TI".m[1] # => "2.5.0" ;TI"=m.values_at(1, 2) # => ["2.5.0", "MatchData"] ;T:@format0S:RDoc::Markup::Heading: leveli: textI"!Global variables equivalence;T@o; ;[I"SParts of last <code>MatchData</code> (returned by Regexp.last_match) are also ;TI"!aliased as global variables:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"7<code>$~</code> is <code>Regexp.last_match</code>;;To;;0;[o; ;[I":<code>$&</code> is <code>Regexp.last_match[0]</code>;;To;;0;[o; ;[I"5<code>$1</code>, <code>$2</code>, and so on are ;TI"<<code>Regexp.last_match[i]</code> (captures by number);;To;;0;[o; ;[I"A<code>$`</code> is <code>Regexp.last_match.pre_match</code>;;To;;0;[o; ;[I"B<code>$'</code> is <code>Regexp.last_match.post_match</code>;;To;;0;[o; ;[I"N<code>$+</code> is <code>Regexp.last_match[-1]</code> (the last capture).;T@o; ;[I"ISee also "Special global variables" section in Regexp documentation.;T: @fileI" re.c;T:0@omit_headings_from_table_of_contents_below0;0;0[ [ [ [[I" class;T[[:public[ [:protected[ [:private[ [I" instance;T[[;[[I"==;TI"../re.c;T[I"[];T@o[I" begin;T@o[I" captures;T@o[I"end;T@o[I" eql?;T@o[I" hash;T@o[I"inspect;T@o[I"length;T@o[I"named_captures;T@o[I" names;T@o[I"offset;T@o[I"post_match;T@o[I"pre_match;T@o[I"regexp;T@o[I" size;T@o[I"string;T@o[I" to_a;T@o[I" to_s;T@o[I"values_at;T@o[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[I"lib/pp.rb;T@Z@ZcRDoc::TopLevel