⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
self
/
root
/
usr
/
share
/
ri
/
3.0.0
/
system
/
String
/
View File Name :
gsub-i.ri
U:RDoc::AnyMethod[iI" gsub:ETI"String#gsub;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"CReturns a copy of
str
with
all
occurrences of ;TI"O
pattern
substituted for the second argument. The
pattern
is ;TI"3typically a Regexp; if given as a String, any ;TI"Gregular expression metacharacters it contains will be interpreted ;TI"Mliterally, 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 the matched text. ;TI"PIt may contain back-references to the pattern's capture groups of the form ;TI";
\d
, where
d
is a group number, or ;TI"9
\k
, where
n
is a group name. ;TI"GSimilarly,
\&
,
\'
,
\`
, and ;TI"G
\+
correspond to special variables,
$&
, ;TI"J
$'
,
$`
, and
$+
, respectively. ;TI"-(See rdoc-ref:regexp.rdoc for details.) ;TI"5
\0
is the same as
\&
. ;TI"N
\\\\
is interpreted as an escape, i.e., a single backslash. ;TI"JNote that, within +replacement+ the special match variables, such as ;TI":
$&
, will not refer to the current match.;T@o; ; [I"CIf 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"E
$&
, and
$'
will be set appropriately. ;TI"-(See rdoc-ref:regexp.rdoc for details.) ;TI"OThe value returned by the block will be substituted for the match on each ;TI" call.;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>') #=> "h
ll
" ;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:@format0o; ; [I"6Note that a string literal consumes backslashes. ;TI"I(See rdoc-ref:syntax/literals.rdoc for details on string literals.) ;TI"HBack-references are typically preceded by an additional backslash. ;TI"KFor example, if you want to write a back-reference
\&
in ;TI"K+replacement+ with a double-quoted string literal, you need to write: ;TI"
"..\\\\&.."
. ;TI"IIf you want to write a non-back-reference string
\&
in ;TI"F+replacement+, you need first to escape the backslash to prevent ;TI"Hthis method from interpreting it as a back-reference, and then you ;TI"Kneed to escape the backslashes again to prevent a string literal from ;TI"3consuming them:
"..\\\\\\\\&.."
. ;TI"FYou may want to use the block form to avoid a lot of backslashes.;T: @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@GFI"String;TcRDoc::NormalClass00