U:RDoc::AnyMethod[iI" gsub:ETI"String#gsub;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"GReturns a copy of str with the all occurrences of ;TI"Opattern substituted for the second argument. The pattern is ;TI"Mtypically a Regexp
; if given as a String
, any ;TI"Gregular expression metacharacters it contains will be interpreted ;TI"Qliterally, e.g. '\\\d'
will match a backslash followed by 'd', ;TI"instead of a digit.;To:RDoc::Markup::BlankLine o;
; [I"OIf replacement is a String
it will be substituted for ;TI"Othe matched text. It may contain back-references to the pattern's capture ;TI"Pgroups of the form \\\d
, where d is a group number, or ;TI"F\\\k
, where n is a group name. If it is a ;TI"Gdouble-quoted string, both back-references must be preceded by an ;TI"Padditional backslash. However, within replacement the special match ;TI"Mvariables, such as $&
, will not refer to the current match.;T@o;
; [I"PIf the second argument is a Hash
, and the matched text is one ;TI"Dof its keys, the corresponding value is the replacement string.;T@o;
; [ I"NIn the block form, the current match string is passed in as a parameter, ;TI"Nand variables such as $1
, $2
, $`
, ;TI"O$&
, and $'
will be set appropriately. The value ;TI"Jreturned by the block will be substituted for the match on each call.;T@o;
; [I"MThe result inherits any tainting in the original string or any supplied ;TI"replacement string.;T@o;
; [I"@When neither a block nor a second argument is supplied, an ;TI")Enumerator
is returned.;T@o:RDoc::Markup::Verbatim; [
I"?"hello".gsub(/[aeiou]/, '*') #=> "h*ll*"
;TI"C"hello".gsub(/([aeiou])/, '<\1>') #=> "hll"
;TI"N"hello".gsub(/./) {|s| s.ord.to_s + ' '} #=> "104 101 108 108 111 "
;TI"C"hello".gsub(/(?[aeiou])/, '{\k}') #=> "h{e}ll{o}"
;TI">'hello'.gsub(/[eo]/, 'e' => 3, 'o' => '*') #=> "h3ll*";T:@format0:
@fileI"
string.c;T:0@omit_headings_from_table_of_contents_below0I"Ãstr.gsub(pattern, replacement) -> new_str
str.gsub(pattern, hash) -> new_str
str.gsub(pattern) {|match| block } -> new_str
str.gsub(pattern) -> enumerator
;T0[ I"(*args);T@6FI"String;TcRDoc::NormalClassI"
scanf;T0