るりまサーチ

最速Rubyリファレンスマニュアル検索!
4件ヒット [1-4件を表示] (0.057秒)
トップページ > クラス:String[x] > クエリ:string[x] > クエリ:tr[x] > クエリ:b[x] > クエリ:byterindex[x]

別のキーワード

  1. matrix tr
  2. string tr
  3. string tr_s
  4. string tr_s!
  5. string tr!

ライブラリ

検索結果

String#byterindex(pattern, offset = self.bytesize) -> Integer | nil (36458.0)

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

...列または正規表現で指定します。

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

byterindex
String#byteindex とでは、探索方向だけが逆になります。
完全に左右が反転した動作をするわけではありません...
...list[String#byteindex の場合][ruby]{
p "stringstring".byteindex("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}

//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex("ing...
...o'.byterindex('o', 0) # => nil
'foo'.byterindex('o', 1) # => 1
'foo'.byterindex('o', 2) # => 2
'foo'.byterindex('o', 3) # => 2

'foo'.byterindex('o', -1) # => 2
'foo'.byterindex('o', -2) # => 1
'foo'.byterindex('o', -3) # => nil
'foo'.byterindex('o', -4) # => nil
//}

@see String#rindex, String#byte...

String#byteindex(pattern, offset = 0) -> Integer | nil (18119.0)

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

...ist[例][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'.byteindex('...
...byteindex('o', -3) # => 1
'foo'.byteindex('o', -4) # => nil

'あいう'.byteindex('う') # => 6
'あいう'.byteindex('う', 3) # => 6
'あいう'.byteindex('う', -3) # => 6
'あいう'.byteindex('う', 1) # offset 1 does not land on character boundary (IndexError)
//}

@see String#index, String#b...