別のキーワード
キーワード
- % (12)
- * (12)
- + (12)
- +@ (10)
- -@ (10)
- << (12)
- <=> (12)
- == (12)
- === (12)
- =~ (12)
- [] (72)
- []= (84)
-
append
_ as _ bytes (1) - byterindex (3)
- bytes (24)
- capitalize! (12)
- casecmp (12)
- casecmp? (9)
- center (12)
- chars (24)
- chomp (12)
- chomp! (12)
- chop! (12)
- chr (12)
- codepoints (24)
- concat (21)
- count (12)
- crypt (12)
- dedup (3)
- delete (12)
- delete! (12)
-
delete
_ prefix! (8) -
delete
_ suffix! (8) - downcase! (12)
-
each
_ byte (24) -
each
_ char (24) -
each
_ codepoint (24) -
each
_ grapheme _ cluster (16) -
each
_ line (24) - encode (36)
- encode! (24)
-
end
_ with? (12) -
force
_ encoding (12) -
grapheme
_ clusters (16) - gsub! (48)
- hash (12)
- hex (12)
- insert (12)
- lines (24)
- ljust (12)
- match (24)
- match? (9)
- next! (12)
- ord (12)
-
parse
_ csv (12) - partition (12)
- rindex (12)
- rjust (12)
- rpartition (12)
- rstrip! (12)
- scan (24)
- scrub (36)
- scrub! (36)
- slice (72)
- split (14)
- squeeze! (12)
-
start
_ with? (12) - strip! (12)
- sub! (36)
- succ! (12)
- swapcase! (12)
-
tr
_ s! (12) - undump (8)
-
unicode
_ normalize (11) -
unicode
_ normalize! (11) -
unicode
_ normalized? (11) - upcase! (12)
- upto (12)
検索結果
先頭5件
-
String
# strip! -> self | nil (127.0) -
先頭と末尾の空白文字を全て破壊的に取り除きます。 空白文字の定義は " \t\r\n\f\v\0" です。
...。
空白文字の定義は " \t\r\n\f\v\0" です。
strip! は、内容を変更した self を返します。
ただし取り除く空白がなかったときは nil を返します。
//emlist[例][ruby]{
str = " abc\r\n"
p str.strip! #=> "abc"
p str #=> "abc"
str = "abc"
p s......tr.strip! #=> nil
p str #=> "abc"
str = " \0 abc \0"
str.strip!
p str #=> "abc"
//}
@see String#strip, String#lstrip... -
String
# swapcase! -> self | nil (127.0) -
'A' から 'Z' までのアルファベット大文字を小文字に、 'a' から 'z' までのアルファベット小文字を大文字に、破壊的に変更します。
... self を変更して返しますが、
置換が起こらなかった場合は nil を返します。
このメソッドはマルチバイト文字を認識しません。
//emlist[例][ruby]{
str = "ABCxyz"
str.swapcase!
p str # => "abcXYZ"
//}
@see String#swapcase, String#upcase!, String#dow......ncase!, String#capitalize!... -
String
# upcase!(*options) -> self | nil (127.0) -
全ての小文字を対応する大文字に破壊的に置き換えます。 どの文字がどう置き換えられるかは、オプションの有無や文字列のエンコーディングに依存します。
...ディングに依存します。
@param options オプションの詳細は String#downcase を参照してください。
//emlist[例][ruby]{
buf = "stRIng? STring."
buf.upcase!
p buf # => "STRING? STRING."
//}
@see String#upcase, String#downcase!,
String#swapcase!, String#capitalize!... -
String
# scan(pattern) {|s| . . . } -> self (125.0) -
pattern がマッチした部分文字列をブロックに渡して実行します。 pattern が正規表現で括弧を含む場合は、 括弧で括られたパターンにマッチした文字列の配列を渡します。
...含む場合は、
括弧で括られたパターンにマッチした文字列の配列を渡します。
@param pattern 探索する部分文字列または正規表現
//emlist[例][ruby]{
"foobarbazfoobarbaz".scan(/ba./) {|s| p s }
# "bar"
# "baz"
# "bar"
# "baz"
"foobarbazfoobarbaz".scan("ba... -
String
# each _ byte {|byte| . . . } -> self (121.0) -
文字列の各バイトに対して繰り返します。
...文字列の各バイトに対して繰り返します。
//emlist[例][ruby]{
"str".each_byte do |byte|
p byte
end
# => 115
# => 116
# => 114
"あ".each_byte do |byte|
p byte
end
# => 227
# => 129
# => 130
//}
@see String#bytes... -
String
# each _ char {|cstr| block } -> self (121.0) -
文字列の各文字に対して繰り返します。
...文字列の各文字に対して繰り返します。
たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界
@see String#chars... -
String
# each _ codepoint {|codepoint| block } -> self (121.0) -
文字列の各コードポイントに対して繰り返します。
...ます。
//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}
@see String#codepoints... -
String
# each _ grapheme _ cluster {|grapheme _ cluster| block } -> self (121.0) -
文字列の書記素クラスタに対して繰り返します。
...。
String#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。
//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster.to_a.size # => 1
//}
@see String#g... -
String
# force _ encoding(encoding) -> self (121.0) -
文字列の持つエンコーディング情報を指定された encoding に変えます。
...イト列のエンコーディングを指定する時に使います。
@param encoding 変更するエンコーディング情報を表す文字列か Encoding オブジェクトを指定します。
//emlist[例][ruby]{
s = [164, 164, 164, 237, 164, 207].pack("C*")
p s.encoding... -
String
# rstrip! -> self | nil (121.0) -
文字列の末尾にある空白文字を全て破壊的に取り除きます。 空白文字の定義は " \t\r\n\f\v\0" です。
...的に取り除きます。
空白文字の定義は " \t\r\n\f\v\0" です。
//emlist[例][ruby]{
str = " abc\n"
p str.rstrip! # => " abc"
p str # => " abc"
str = " abc \r\n\t\v\0"
p str.rstrip! # => " abc"
p str # => " abc"
//}
@see String#rstrip, String#lstrip... -
String
# squeeze!(*chars) -> self | nil (121.0) -
chars に含まれる文字が複数並んでいたら 1 文字にまとめます。
...る文字を 1 文字にまとめます。
1 文字もまとめられなかった場合は nil を返します。
@param chars 1文字にまとめる文字。
//emlist[例][ruby]{
str = "112233445566778899"
str.squeeze!
p str # =>"123456789"
str = "112233445566778899"
str.squeeze!("2-8")
p...