るりまサーチ

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

別のキーワード

  1. _builtin nil?
  2. nilclass nil?
  3. object nil?
  4. _builtin nil
  5. object nil

ライブラリ

クラス

検索結果

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

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

...返します。
見つからなければ nil を返します。

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

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

byterindex
と String#byteindex とでは、探索方...
...ら探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}

//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex("ing", -1) # => 9
# ing # インデックス -1 の文字から探索を始める
# ing
#...
...{
'foo'.byterindex('f') # => 0
'foo'.byterindex('o') # => 2
'foo'.byterindex('oo') # => 1
'foo'.byterindex('ooo') # => nil

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

# 右でのマッチが優先
'foo'.byterindex(/o+/) #...

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

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

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

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

offset が負の場合、文字列の...
...('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('o', 2) # => 2
'foo'.byteindex('o', 3) # => nil

'foo'.byteindex('o', -1) # => 2
'foo'.b...
...'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#byterindex...