U:RDoc::AnyMethod[iI"=~:ETI"Regexp#=~;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"3Match---Matches rxp against str.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I""/at/ =~ "input data" #=> 7 ;TI"$/ax/ =~ "input data" #=> nil ;T: @format0o; ; [I"KIf =~ is used with a regexp literal with named captures, ;TI"Gcaptured strings (or nil) is assigned to local variables named by ;TI"the capture names.;T@o; ; [I"4/(?\w+)\s*=\s*(?\w+)/ =~ " x = y " ;TI"p lhs #=> "x" ;TI"p rhs #=> "y" ;T; 0o; ; [I"=If it is not matched, nil is assigned for the variables.;T@o; ; [I"1/(?\w+)\s*=\s*(?\w+)/ =~ " x = " ;TI"p lhs #=> nil ;TI"p rhs #=> nil ;T; 0o; ; [I"8This assignment is implemented in the Ruby parser. ;TI"KThe parser detects 'regexp-literal =~ expression' for the assignment. ;TI"UThe regexp must be a literal without interpolation and placed at left hand side.;T@o; ; [I"BThe assignment does not occur if the regexp is not a literal.;T@o; ; [ I"*re = /(?\w+)\s*=\s*(?\w+)/ ;TI"re =~ " x = y " ;TI")p lhs # undefined local variable ;TI")p rhs # undefined local variable ;T; 0o; ; [I"=A regexp interpolation, #{}, also disables ;TI"the assignment.;T@o; ; [I"rhs_pat = /(?\w+)/ ;TI"//(?\w+)\s*=\s*#{rhs_pat}/ =~ "x = y" ;TI")p lhs # undefined local variable ;T; 0o; ; [I"RThe assignment does not occur if the regexp is placed at the right hand side.;T@o; ; [I"4" x = y " =~ /(?\w+)\s*=\s*(?\w+)/ ;TI"*p lhs, rhs # undefined local variable;T; 0: @fileI" re.c;T:0@omit_headings_from_table_of_contents_below0I"%rxp =~ str -> integer or nil ;T0[I" (p1);T@CFI" Regexp;TcRDoc::NormalClass00