⚝
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 :
~
/
usr
/
share
/
ri
/
3.0.0
/
system
/
String
/
Edit File: 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. <code>\d</code> 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";<code>\d</code>, where <i>d</i> is a group number, or ;TI"9<code>\k<n></code>, where <i>n</i> is a group name. ;TI"GSimilarly, <code>\&</code>, <code>\'</code>, <code>\`</code>, and ;TI"G<code>\+</code> correspond to special variables, <code>$&</code>, ;TI"J<code>$'</code>, <code>$`</code>, and <code>$+</code>, respectively. ;TI"-(See rdoc-ref:regexp.rdoc for details.) ;TI"5<code>\0</code> is the same as <code>\&</code>. ;TI"N<code>\\\\</code> is interpreted as an escape, i.e., a single backslash. ;TI"JNote that, within +replacement+ the special match variables, such as ;TI":<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"E<code>$&</code>, and <code>$'</code> 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<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:@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 <code>\&</code> in ;TI"K+replacement+ with a double-quoted string literal, you need to write: ;TI"<code>"..\\\\&.."</code>. ;TI"IIf you want to write a non-back-reference string <code>\&</code> 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: <code>"..\\\\\\\\&.."</code>. ;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
Simpan