ライブラリ
- ビルトイン (183)
検索結果
先頭5件
-
String
# bytes -> [Integer] (24328.0) -
文字列の各バイトを数値の配列で返します。(self.each_byte.to_a と同じです)
..._byte.to_a と同じです)
//emlist[例][ruby]{
"str".bytes # => [115, 116, 114]
//}
ブロックが指定された場合は String#each_byte と同じように動作します。
Ruby 2.6 までは deprecated の警告が出ますが、Ruby 2.7 で警告は削除されました。
@see String#e......ach_byte... -
String
# bytes {|byte| . . . } -> self (24328.0) -
文字列の各バイトを数値の配列で返します。(self.each_byte.to_a と同じです)
..._byte.to_a と同じです)
//emlist[例][ruby]{
"str".bytes # => [115, 116, 114]
//}
ブロックが指定された場合は String#each_byte と同じように動作します。
Ruby 2.6 までは deprecated の警告が出ますが、Ruby 2.7 で警告は削除されました。
@see String#e......ach_byte... -
String
# bytesize -> Integer (12308.0) -
文字列のバイト長を整数で返します。
...文字列のバイト長を整数で返します。
//emlist[例][ruby]{
#coding:UTF-8
# 実行結果は文字コードによって異なります。
p "いろは".size #=> 3
p "いろは".bytesize #=> 9
//}
@see String#size... -
String
# byteslice(nth) -> String | nil (12210.0) -
nth バイト目の文字を返します。nth が負の場合は文字列の末尾から数えます。 引数が範囲外を指定した場合は nil を返します。
...nth バイト目の文字を返します。nth が負の場合は文字列の末尾から数えます。
引数が範囲外を指定した場合は nil を返します。
@param nth 文字の位置を表す整数を指定します。
@return 切り出した文字列を返します。戻り値の......文字エンコーディングは自身
と同じです。
//emlist[例][ruby]{
"hello".byteslice(1) # => "e"
"hello".byteslice(-1) # => "o"
"\u3042".byteslice(0) # => "\xE3"
"\u3042".byteslice(1) # => "\x81"
//}
@see String#slice... -
String
# byteslice(nth , len=1) -> String | nil (12210.0) -
nth バイト目から長さ len バイトの部分文字列を新しく作って返します。 nth が負の場合は文字列の末尾から数えます。引数が範囲外を指定した場合は nil を返します。
...nth バイト目から長さ len バイトの部分文字列を新しく作って返します。
nth が負の場合は文字列の末尾から数えます。引数が範囲外を指定した場合は
nil を返します。
@param nth 取得したい文字列の開始バイトを整数で指定し......数で指定します。
@return 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。
//emlist[例][ruby]{
"hello".byteslice(1, 2) # => "el"
"\u3042\u3044\u3046".byteslice(0, 3) # => "\u3042"
//}
@see String#slice......。
@return 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。
//emlist[例][ruby]{
"hello".byteslice(1, 2) # => "el"
"\u3042\u3044\u3046".byteslice(0, 3) # => "\u3042"
//}
@see String#slice
@see String#bytesplice... -
String
# byteslice(range) -> String | nil (12210.0) -
range で指定したバイトの範囲に含まれる部分文字列を返します。引数が範囲 外を指定した場合は nil を返します。
...を示す Range オブジェクト
@return 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。
//emlist[例][ruby]{
"hello".byteslice(1..2) # => "el"
"\x03\u3042\xff".byteslice(1..3) # => "\u3042"
//}
@see String#slice......ェクト
@return 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。
//emlist[例][ruby]{
"hello".byteslice(1..2) # => "el"
"\x03\u3042\xff".byteslice(1..3) # => "\u3042"
//}
@see String#slice
@see String#bytesplice... -
String
# byterindex(pattern , offset = self . bytesize) -> Integer | nil (6520.0) -
文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...イト単位のインデックス offset から左に向かって pattern を探索します。
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。
引数 pattern は探索する部分文字列ま......たは正規表現で指定します。
offset が負の場合は、文字列の末尾から数えた位置から探索します。
byterindex と String#byteindex とでは、探索方向だけが逆になります。
完全に左右が反転した動作をするわけではありません。
探......//emlist[String#byteindex の場合][ruby]{
p "stringstring".byteindex("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}
//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex... -
String
# each _ byte {|byte| . . . } -> self (6214.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 _ byte -> Enumerator (6114.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
# getbyte(index) -> Integer | nil (6114.0) -
index バイト目のバイトを整数で返します。
...定した場合は nil を返します。
@param index バイトを取り出す位置
//emlist[例][ruby]{
s = "tester"
s.bytes # => [116, 101, 115, 116, 101, 114]
s.getbyte(0) # => 116
s.getbyte(1) # => 101
s.getbyte(-1) # => 114
s.getbyte(6) # => nil
//}...