るりまサーチ

最速Rubyリファレンスマニュアル検索!
1122件ヒット [1-100件を表示] (0.176秒)
トップページ > クエリ:t[x] > クエリ:ruby[x] > クエリ:String[x] > クエリ:string[x] > クエリ:@[x] > クエリ:Integer[x]

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

String#byterindex(pattern, offset = self.bytesize) -> Integer | nil (36597.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#byteindex(pattern, offset = 0) -> Integer | nil (36455.0)

文字列の offset から右に向かって pattern を検索し、 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。

...文字列の offset から右に向かって pattern を検索し、
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。

引数 pattern は探索する部分文字列または正規表現で指定...
...します。

offset が負の場合、文字列の末尾から数えた位置から探索します。

@
param pattern 探索する部分文字列または正規表現
@
param offset 探索を開始するバイト単位のオフセット

@
raise IndexError オフセットが文字列の境界...
...emlist[例][ruby]{
'foo'.byteindex('f') # => 0
'foo'.byteindex('o') # => 1
'foo'.byteindex('oo') # => 1
'foo'.byteindex('ooo') # => nil

'foo'.byteindex(/f/) # => 0
'foo'.byteindex(/o/) # => 1
'foo'.byteindex(/oo/) # => 1
'foo'.byteindex(/ooo/) # => nil

'foo'.byteindex('o', 1) # => 1
'foo'.byteinde...

String#bytes -> [Integer] (36349.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 (36325.0)

文字列のバイト長を整数で返します。

...文字列のバイト長を整数で返します。

//emlist[例][ruby]{
#coding:UTF-8
# 実行結果は文字コードによって異なります。
p "いろは".size #=> 3
p "いろは".bytesize #=> 9
//}

@
see String#size...

String#to_i(base = 10) -> Integer (36297.0)

文字列を 10 進数表現された整数であると解釈して、整数に変換します。

...ist[例][ruby]{
p " 10".to_i # => 10
p "+10".to_i # => 10
p "-10".to_i # => -10

p "010".to_i # => 10
p "-010".to_i # => -10
//}

整数とみなせない文字があればそこまでを変換対象とします。
変換対象が空文字列であれば 0 を返します。

//emlist[...
...][ruby]{
p "01".to_i(2) # => 1
p "0b1".to_i(2) # => 1

p "07".to_i(8) # => 7
p "0o7".to_i(8) # => 7

p "1f".to_i(16) # => 31
p "0x1f".to_i(16) # => 31

p "0b10".to_i(0) # => 2
p "0o10".to_i(0) # => 8
p "010".to_i(0) # => 8
p "0d10".to_i(0) # => 10
p "0x10".to_i(0) # => 16
//}

@
par...
...する整数。0 か、2〜36 の整数。
@
return 整数

このメソッドの逆に数値を文字列に変換するには、
Kernel.#sprintf, String#%, Integer#to_s
を使用します。

String
#hex, String#oct, String#to_f,
Kernel.#Integer, Kernel.#Float
も参照してください。...

絞り込み条件を変える

String#oct -> Integer (36285.0)

文字列を 8 進文字列であると解釈して、整数に変換します。

...//emlist[例][ruby]{
p "10".oct # => 8
p "010".oct # => 8
p "8".oct # => 0
//}

oct は文字列の接頭辞 ("0", "0b", "0B", "0x", "0X") に応じて
8 進以外の変換も行います。

//emlist[例][ruby]{
p "0b10".oct # => 2
p "10".oct # => 8
p "010".oct # => 8
p "0x10".oct # => 1...
...//emlist[例][ruby]{
p "-010".oct # => -8
p "-0x10".oct # => -16
p "-0b10".oct # => -2

p "1_0_1x".oct # => 65
//}

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

逆に、数値を文字列に変換するにはKernel.#sprintf,
String
#%, Integer#to_s を...

String#bytes {|byte| ... } -> self (36249.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#codepoints -> [Integer] (36249.0)

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

...odepoint.to_a と同じです)

//emlist[例][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#length -> Integer (36226.0)

文字列の文字数を返します。バイト数を知りたいときは bytesize メソッドを使ってください。

...いときは bytesize メソッドを使ってください。

//emlist[例][ruby]{
"test".length # => 4
"test".size # => 4
"テスト".length # => 3
"テスト".size # => 3
"\x80\u3042".length # => 2
"\x80\u3042".size # => 2
//}

@
see String#bytesize...

String#setbyte(index, b) -> Integer (36225.0)

index バイト目のバイトを b に変更します。

...を返します。

@
param index バイトをセットする位置
@
param b セットするバイト(0 から 255 までの整数)
@
raise IndexError 範囲外に値をセットしようとした場合に発生します。

//emlist[例][ruby]{
s = "Sunday"
s.setbyte(0, 77)
s.setbyte(-5, 111)
s # =>...

絞り込み条件を変える

<< 1 2 3 ... > >>