るりまサーチ

最速Rubyリファレンスマニュアル検索!
1875件ヒット [1301-1400件を表示] (0.120秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< < ... 12 13 14 15 16 ... > >>

String#bytes {|byte| ... } -> self (9038.0)

文字列の各バイトを数値の配列で返します。(self.each_byte.to_a と同じです)

...と同じです)

//emlist[例][ruby]{
"str".bytes # => [115, 116, 114]
//}

ブロックが指定された場合は String#each_byte と同じように動作します。

Ruby
2.6 までは deprecated の警告が出ますが、Ruby 2.7 で警告は削除されました。

@
see String#each_byte...

String#codepoints -> [Integer] (9038.0)

文字列の各コードポイントの配列を返します。(self.each_codepoint.to_a と同じです)

...ist[例][ruby]{
#coding:UTF-8
"hello わーるど".codepoints
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
//}

ブロックが指定された場合は String#each_codepoint と同じように動作します。

Ruby
2.6 までは deprecated の警告が出ますが、Ruby 2.7 で...
...警告は削除されました。

@
see String#each_codepoint...

String#codepoints {|codepoint| block } -> self (9038.0)

文字列の各コードポイントの配列を返します。(self.each_codepoint.to_a と同じです)

...ist[例][ruby]{
#coding:UTF-8
"hello わーるど".codepoints
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
//}

ブロックが指定された場合は String#each_codepoint と同じように動作します。

Ruby
2.6 までは deprecated の警告が出ますが、Ruby 2.7 で...
...警告は削除されました。

@
see String#each_codepoint...

String#encode!(encoding, from_encoding, options = nil) -> self (9038.0)

self を指定したエンコーディングに変換し、自身を置き換えます。引数を2つ 与えた場合、第二引数は変換元のエンコーディングを意味します。さもなくば self のエンコーディングが使われます。変換後の self を返します。

...f を返します。

@
param encoding 変換先のエンコーディングを表す文字列か Encoding オブジェクトを指定します。
@
param from_encoding 変換元のエンコーディングを表す文字列か Encoding オブジェクトを指定します。
@
return...
...変換後のself

//emlist[例][ruby]{
#coding:UTF-8
s = "いろは"
s.encode!("EUC-JP")
s.encode!(Encoding::UTF_8)
//}

@
see String#encode...

String#encode!(encoding, options = nil) -> self (9038.0)

self を指定したエンコーディングに変換し、自身を置き換えます。引数を2つ 与えた場合、第二引数は変換元のエンコーディングを意味します。さもなくば self のエンコーディングが使われます。変換後の self を返します。

...f を返します。

@
param encoding 変換先のエンコーディングを表す文字列か Encoding オブジェクトを指定します。
@
param from_encoding 変換元のエンコーディングを表す文字列か Encoding オブジェクトを指定します。
@
return...
...変換後のself

//emlist[例][ruby]{
#coding:UTF-8
s = "いろは"
s.encode!("EUC-JP")
s.encode!(Encoding::UTF_8)
//}

@
see String#encode...

絞り込み条件を変える

String#hex -> Integer (9038.0)

文字列に 16 進数で数値が表現されていると解釈して整数に変換します。 接頭辞 "0x", "0X" とアンダースコアは無視されます。 文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。

...0 を返します。

//emlist[例][ruby]{
p "10".hex # => 16
p "ff".hex # => 255
p "0x10".hex # => 16
p "-0x10".hex # => -16

p "xyz".hex # => 0
p "10z".hex # => 16
p "1_0".hex # => 16

p "".hex # => 0
//}

@
see String#oct, String#to_i, String#to_f,
Kernel.#Integer, Kernel.#...
...Float

このメソッドの逆に数値を文字列に変換するには
Kernel.#sprintf, String#%,
Integer#to_s
などを使ってください。...

String#swapcase! -> self | nil (9038.0)

'A' から 'Z' までのアルファベット大文字を小文字に、 'a' から 'z' までのアルファベット小文字を大文字に、破壊的に変更します。

...すが、
置換が起こらなかった場合は nil を返します。

このメソッドはマルチバイト文字を認識しません。

//emlist[例][ruby]{
str = "ABCxyz"
str.swapcase!
p str # => "abcXYZ"
//}

@
see String#swapcase, String#upcase!, String#downcase!, String#capitalize!...

String#unicode_normalize!(form = :nfc) -> self (9038.0)

self を NFC、NFD、NFKC、NFKD のいずれかの正規化形式で Unicode 正規化し た文字列に置き換えます。

...と異なり)変換が行なわれなくても self を返します。

@
param form 正規化形式を :nfc、:nfd、:nfkc、:nfkd のいずれかで指定しま
す。省略した場合は :nfc になります。

@
raise Encoding::CompatibilityError self が Unicode 文字列ではな...
...に発生します。

//emlist[例][ruby]{
text = "a\u0300"
text.unicode_normalize!(:nfc)
text == "\u00E0" # => true
text.unicode_normalize!(:nfd)
text == "a\u0300" # => true
//}

@
see String#unicode_normalize, String#unicode_normalized?...

String#unicode_normalized?(form = :nfc) -> bool (9038.0)

self が引数 form で指定された正規化形式で Unicode 正規化された文字列か どうかを返します。

...で Unicode 正規化された文字列か
どうかを返します。

@
param form 正規化形式を :nfc、:nfd、:nfkc、:nfkd のいずれかで指定しま
す。省略した場合は :nfc になります。

@
raise Encoding::CompatibilityError self が Unicode 文字列ではな...
...い場合
に発生します。

//emlist[例][ruby]{
"a\u0300".unicode_normalized? # => false
"a\u0300".unicode_normalized?(:nfd) # => true
"\u00E0".unicode_normalized? # => true
"\u00E0".unicode_normalized?(:nfd) # => false
"\xE0".force_encodin...
...g('ISO-8859-1').unicode_normalized?
# => Encoding::CompatibilityError raised
//}

@
see String#unicode_normalize, String#unicode_normalize!...

String#gsub!(pattern, hash) -> self | nil (9037.0)

文字列中の pattern にマッチした部分をキーにして hash を引いた値へ破壊的に置き換えます。

...をキーにして hash を引いた値へ破壊的に置き換えます。

@
param pattern 置き換える文字列のパターン
@
param hash 置き換える文字列を与えるハッシュ

//emlist[例][ruby]{
hash = {'b'=>'B', 'c'=>'C'}
str = "abcabc"
str.gsub!(/[bc]/){hash[$&]}
p str...

絞り込み条件を変える

<< < ... 12 13 14 15 16 ... > >>