2件ヒット
[1-2件を表示]
(0.048秒)
ライブラリ
- ビルトイン (2)
検索結果
先頭2件
-
String
# rindex(pattern , pos = self . size) -> Integer | nil (54811.0) -
文字列のインデックス pos から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のインデックスを返します。 見つからなければ nil を返します。
...列または正規表現で指定します。
pos が負の場合は、文字列の末尾から数えた位置から探索します。
rindex と String#index とでは、探索方向だけが逆になります。
完全に左右が反転した動作をするわけではありません。
探索......い。
//emlist[String#index の場合][ruby]{
p "stringstring".index("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}
//emlist[String#rindex の場合][ruby]{
p "stringstring".rindex("ing", -......ンデックス
//emlist[例][ruby]{
p "astrochemistry".rindex("str") # => 10
p "character".rindex(?c) # => 5
p "regexprindex".rindex(/e.*x/, 2) # => 1
p "foobarfoobar".rindex("bar", 6) # => 3
p "foobarfoobar".rindex("bar", -6) # => 3
//}
@see String#index... -
String
# byterindex(pattern , offset = self . bytesize) -> Integer | nil (18679.0) -
文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...は正規表現で指定します。
offset が負の場合は、文字列の末尾から数えた位置から探索します。
byterindex と String#byteindex とでは、探索方向だけが逆になります。
完全に左右が反転した動作をするわけではありません。
探索......//emlist[String#byteindex の場合][ruby]{
p "stringstring".byteindex("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}
//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterinde......erindex('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#byteindex...