D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
String
/
Filename :
scan-i.ri
back
Copy
U:RDoc::AnyMethod[iI" scan:ETI"String#scan;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"6Matches a pattern against +self+; the pattern is:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"2+string_or_regexp+ itself, if it is a Regexp.;To;;0; [o; ; [I"P<tt>Regexp.quote(string_or_regexp)</tt>, if +string_or_regexp+ is a string.;T@o; ; [I"JIterates through +self+, generating a collection of matching results:;T@o;; ;;[o;;0; [o; ; [I";If the pattern contains no groups, each result is the ;TI"%matched string, <code>$&</code>.;To;;0; [o; ; [I"=If the pattern contains groups, each result is an array ;TI"$containing one entry per group.;T@o; ; [I":With no block given, returns an array of the results:;T@o:RDoc::Markup::Verbatim; [ I"s = 'cruel world' ;TI"0s.scan(/\w+/) # => ["cruel", "world"] ;TI"3s.scan(/.../) # => ["cru", "el ", "wor"] ;TI"9s.scan(/(...)/) # => [["cru"], ["el "], ["wor"]] ;TI":s.scan(/(..)(..)/) # => [["cr", "ue"], ["l ", "wo"]] ;T:@format0o; ; [I"JWith a block given, calls the block with each result; returns +self+:;T@o;; [ I",s.scan(/\w+/) {|w| print "<<#{w}>> " } ;TI"print "\n" ;TI"*s.scan(/(.)(.)/) {|x,y| print y, x } ;TI"print "\n" ;T;0o; ; [I"Output:;T@o;; [I"<<cruel>> <<world>> ;TI"rceu lowlr;T;0: @fileI" string.c;T:0@omit_headings_from_table_of_contents_below0I"Uscan(string_or_regexp) -> array scan(string_or_regexp) {|matches| ... } -> self ;T0[ I" (p1);T@FFI"String;TcRDoc::NormalClass00