⚝
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 :
sub-i.ri
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"Kbe interpreted literally, e.g.
\d
will match a backslash ;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";
\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"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
$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:RDoc::Markup::Verbatim; [I">"hello".sub(/[aeiou]/, '*') #=> "h*llo" ;TI"@"hello".sub(/([aeiou])/, '<\1>') #=> "h
llo" ;TI"A"hello".sub(/./) {|s| s.ord.to_s + ' ' } #=> "104 ello" ;TI"@"hello".sub(/(?
[aeiou])/, '*\k
*') #=> "h*e*llo" ;TI"B'Is SHELL your preferred shell?'.sub(/[[:upper:]]{2,}/, ENV) ;TI"/ #=> "Is /bin/bash your preferred shell?" ;T:@format0o; ; [I"6Note that a string literal consumes backslashes. ;TI"L(See rdoc-ref:syntax/literals.rdoc for details about 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.sub(pattern, replacement) -> new_str str.sub(pattern, hash) -> new_str str.sub(pattern) {|match| block } -> new_str ;T0[ I"(*args);T@CFI"String;TcRDoc::NormalClass00