Repository URL to install this package:
|
Version:
2.2.2-1 ▾
|
U:RDoc::AnyMethod[iI"sub:ETI"String#sub;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [
I"FReturns a copy of +str+ with the _first_ occurrence of +pattern+ ;TI"Nreplaced by the second argument. The +pattern+ is typically a Regexp; if ;TI"Ogiven as a String, any regular expression metacharacters it contains will ;TI"Nbe interpreted literally, e.g. <code>'\\\d'</code> will match a backlash ;TI")followed by 'd', instead of a digit.;To:RDoc::Markup::BlankLine o;
; [I"OIf +replacement+ is a String it will be substituted for the matched text. ;TI"PIt may contain back-references to the pattern's capture groups of the form ;TI"><code>"\\d"</code>, where <i>d</i> is a group number, or ;TI"G<code>"\\k<n>"</code>, where <i>n</i> is a group name. If it is a ;TI"Gdouble-quoted string, both back-references must be preceded by an ;TI"Kadditional backslash. However, within +replacement+ the special match ;TI"Mvariables, such as <code>&$</code>, will not refer to the current match.;T@o;
; [I"PIf the second argument is a Hash, and the matched text is one of its keys, ;TI"7the 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 <code>$1</code>, <code>$2</code>, <code>$`</code>, ;TI"O<code>$&</code>, and <code>$'</code> 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:RDoc::Markup::Verbatim; [I">"hello".sub(/[aeiou]/, '*') #=> "h*llo"
;TI"@"hello".sub(/([aeiou])/, '<\1>') #=> "h<e>llo"
;TI"A"hello".sub(/./) {|s| s.ord.to_s + ' ' } #=> "104 ello"
;TI"@"hello".sub(/(?<foo>[aeiou])/, '*\k<foo>*') #=> "h*e*llo"
;TI"B'Is SHELL your preferred shell?'.sub(/[[:upper:]]{2,}/, ENV)
;TI". #=> "Is /bin/bash your preferred shell?";T:@format0:
@fileI"
string.c;T:0@omit_headings_from_table_of_contents_below0I"str.sub(pattern, replacement) -> new_str
str.sub(pattern, hash) -> new_str
str.sub(pattern) {|match| block } -> new_str
;T0[ I"(*args);T@2FI"String;TcRDoc::NormalClassI"
scanf;T0