るりまサーチ

最速Rubyリファレンスマニュアル検索!
402件ヒット [1-100件を表示] (0.051秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

String#index(pattern, pos = 0) -> Integer | nil (27150.0)

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

...ンデックス

//emlist[例][ruby]{
p "astrochemistry".index("str") # => 1
p "regexpindex".index(/e.*x/, 2) # => 3
p "character".index(?c) # => 0

p "foobarfoobar".index("bar", 6) # => 9
p "foobarfoobar".index("bar", -6) # => 9
//}

@see String#rindex...
...mlist[例][ruby]{
p "astrochemistry".index("str") # => 1
p "regexpindex".index(/e.*x/, 2) # => 3
p "character".index(?c) # => 0

p "foobarfoobar".index("bar", 6) # => 9
p "foobarfoobar".index("bar", -6) # => 9
//}

@see String#rindex
@see String#byteindex...

String#rindex(pattern, pos = self.size) -> Integer | nil (15167.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", -1) #...
...ンデックス

//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 (15149.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...
...][ruby]{
'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(...

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

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

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

String#getbyte(index) -> Integer | nil (9136.0)

index バイト目のバイトを整数で返します。

...
index
バイト目のバイトを整数で返します。

index
に負を指定すると末尾から数えた位置のバイト
を取り出します。
範囲外を指定した場合は nil を返します。

@param index バイトを取り出す位置

//emlist[例][ruby]{
s = "tester"
s.bytes...

絞り込み条件を変える

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

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

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

index
に負を指定すると末尾から数えた位置を変更します。

セットした値を返します。

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

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

StringScanner#pointer=(n) (3019.0)

スキャンポインタのインデックスを n にセットします。

...す。

//emlist[例][ruby]{
require 'strscan'

s = StringScanner.new('test string')
p s.scan(/\w+/) # => "test"
p s.pos = 1 # => 1
p s.scan(/\w+/) # => "est"
p s.pos = 7 # => 7
p s.scan(/\w+/) # => "ring"

begin
s.pos = 20
rescue RangeError => err
puts err #=> index out of range
end
p s...

StringScanner#pos=(n) (3019.0)

スキャンポインタのインデックスを n にセットします。

...す。

//emlist[例][ruby]{
require 'strscan'

s = StringScanner.new('test string')
p s.scan(/\w+/) # => "test"
p s.pos = 1 # => 1
p s.scan(/\w+/) # => "est"
p s.pos = 7 # => 7
p s.scan(/\w+/) # => "ring"

begin
s.pos = 20
rescue RangeError => err
puts err #=> index out of range
end
p s...

CSV::Table#[](index) -> CSV::Row | [String] | nil (216.0)

ミックスモードでは、このメソッドは引数に行番号を指定すれば行単位で動作 し、ヘッダの名前を指定すれば列単位で動作します。

..._col! を呼び出すとカラム
モードになります。また CSV::Table#by_row! を呼び出すとロウモード
になります。

@param index ミックスモード・ロウモードでは、取得したい行の行番号を整数で指定します。
カラムモードでは...
...ます。
@param header 取得したい列のヘッダを文字列で指定します。ロウモードでは使用できません。

//emlist[例][ruby]{
require "csv"

row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"]...

MatchData#values_at(*index) -> [String] (215.0)

正規表現中の n 番目の括弧にマッチした部分文字列の配列を返します。

...は $& のようにマッチした文字列全体を表します。

@param index インデックスを整数またはシンボル(名前付きキャプチャの場合)で 0 個以上指定します。

//emlist[例][ruby]{
m = /(foo)(bar)(baz)/.match("foobarbaz")
# same as m.to_a.values_at(...)
p m...

絞り込み条件を変える

<< 1 2 3 ... > >>