⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.116
Server IP:
78.40.11.138
Server:
Linux tango.o2switch.net 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
Server Software:
Apache
PHP Version:
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
opt
/
alt
/
ruby33
/
share
/
ri
/
system
/
View File Name :
page-character_selectors_rdoc.ri
U:RDoc::TopLevel[ i I"character_selectors.rdoc:ETcRDoc::Parser::Simpleo:RDoc::Markup::Document:@parts[%S:RDoc::Markup::Heading: leveli: textI"Character Selectors;To:RDoc::Markup::BlankLine S; ; i;I"Character Selector;T@ o:RDoc::Markup::Paragraph;[I"UA _character_ _selector_ is a string argument accepted by certain Ruby methods. ;TI"LEach of these instance methods accepts one or more character selectors:;T@ o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"=String#tr(selector, replacements): returns a new string.;To;;0;[o; ;[I"AString#tr!(selector, replacements): returns +self+ or +nil+.;To;;0;[o; ;[I"?String#tr_s(selector, replacements): returns a new string.;To;;0;[o; ;[I"CString#tr_s!(selector, replacements): returns +self+ or +nil+.;To;;0;[o; ;[I"MString#count(*selectors): returns the count of the specified characters.;To;;0;[o; ;[I"5String#delete(*selectors): returns a new string.;To;;0;[o; ;[I"9String#delete!(*selectors): returns +self+ or +nil+.;To;;0;[o; ;[I"6String#squeeze(*selectors): returns a new string.;To;;0;[o; ;[I":String#squeeze!(*selectors): returns +self+ or +nil+.;T@ o; ;[I"GA character selector identifies zero or more characters in +self+ ;TI",that are to be operands for the method.;T@ o; ;[I"JIn this section, we illustrate using method String#delete(selector), ;TI"+which deletes the selected characters.;T@ o; ;[I"EIn the simplest case, the characters selected are exactly those ;TI"&contained in the selector itself:;T@ o:RDoc::Markup::Verbatim;[I"/'abracadabra'.delete('a') # => "brcdbr" ;TI"-'abracadabra'.delete('ab') # => "rcdr" ;TI",'abracadabra'.delete('abc') # => "rdr" ;TI"0'0123456789'.delete('258') # => "0134679" ;TI"1'!@#$%&*()_+'.delete('+&#') # => "!@$%*()_" ;TI"2'тест'.delete('т') # => "ес" ;TI"='こんにちは'.delete('に') # => "こんちは" ;T:@format0o; ;[I"3Note that order and repetitions do not matter:;T@ o;;[I",'abracadabra'.delete('dcab') # => "rr" ;TI"0'abracadabra'.delete('aaaa') # => "brcdbr" ;T;0o; ;[I"KIn a character selector, these three characters get special treatment:;T@ o;;;;[o;;0;[o; ;[I"BA leading caret (<tt>'^'</tt>) functions as a "not" operator ;TI"%for the characters to its right:;T@ o;;[I",'abracadabra'.delete('^bc') # => "bcb" ;TI",'0123456789'.delete('^852') # => "258" ;T;0o;;0;[o; ;[I":A hyphen (<tt>'-'</tt>) between two other characters ;TI"Kdefines a range of characters instead of a plain string of characters:;T@ o;;[I"+'abracadabra'.delete('a-d') # => "rr" ;TI"/'0123456789'.delete('4-7') # => "012389" ;TI",'!@#$%&*()_+'.delete(' -/') # => "@^_" ;TI" ;TI"(# May contain more than one range. ;TI"-'abracadabra'.delete('a-cq-t') # => "d" ;TI" ;TI"2# Ranges may be mixed with plain characters. ;TI"/'0123456789'.delete('67-950-23') # => "4" ;TI" ;TI"+# Ranges may be mixed with negations. ;TI"2'abracadabra'.delete('^a-c') # => "abacaaba" ;T;0o;;0;[o; ;[I"IA backslash (<tt>'\'</tt>) acts as an escape for a caret, a hyphen, ;TI"or another backslash:;T@ o;;[ I"5'abracadabra^'.delete('\^bc') # => "araadara" ;TI"2'abracadabra-'.delete('a\-d') # => "brcbr" ;TI"9"hello\r\nworld".delete("\r") # => "hello\nworld" ;TI":"hello\r\nworld".delete("\\r") # => "hello\r\nwold" ;TI"9"hello\r\nworld".delete("\\\r") # => "hello\nworld" ;T;0S; ; i;I"!Multiple Character Selectors;T@ o; ;[I"@These instance methods accept multiple character selectors:;T@ o;;;;[ o;;0;[o; ;[I"MString#count(*selectors): returns the count of the specified characters.;To;;0;[o; ;[I"5String#delete(*selectors): returns a new string.;To;;0;[o; ;[I"9String#delete!(*selectors): returns +self+ or +nil+.;To;;0;[o; ;[I"6String#squeeze(*selectors): returns a new string.;To;;0;[o; ;[I":String#squeeze!(*selectors): returns +self+ or +nil+.;T@ o; ;[I"FIn effect, the given selectors are formed into a single selector ;TI"Pconsisting of only those characters common to _all_ of the given selectors.;T@ o; ;[I"RAll forms of selectors may be used, including negations, ranges, and escapes.;T@ o; ;[I"7Each of these pairs of method calls is equivalent:;T@ o;;[ I" s.delete('abcde', 'dcbfg') ;TI"s.delete('bcd') ;TI" ;TI"s.delete('^abc', '^def') ;TI"s.delete('^abcdef') ;TI" ;TI"s.delete('a-e', 'c-g') ;TI"s.delete('cde');T;0: @file@:0@omit_headings_from_table_of_contents_below0