別のキーワード
検索結果
先頭5件
-
ARGF
. class # pos=(n) (18121.0) -
ARGFが開いているファイルのファイルポインタを指定位置に移動します。
...ARGFが開いているファイルのファイルポインタを指定位置に移動します。
@param n 先頭からのオフセットをバイト単位の整数で指定します。
ARGF.pos = 17
ARGF.gets # => "This is line two\n"
@see IO#pos=, ARGF.class#pos... -
IO
# pos=(n) (18121.0) -
ファイルポインタを指定位置に移動します。 IO#seek(n, IO::SEEK_SET) と同じです。
...です。
@param n 先頭からのオフセットを整数で指定します。
@raise IOError 既に close されている場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "This is line one\nThis is line two\n")
File.open("testfile") do |f|
f.pos # => 0
f.pos = 17
f.... -
Dir
# pos=(pos) (18115.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
...込み位置を pos に移動させます。
pos は Dir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") d... -
Dir
# seek(pos) -> self (3015.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
...込み位置を pos に移動させます。
pos は Dir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") d... -
String
# index(pattern , pos = 0) -> Integer | nil (28.0) -
文字列のインデックス pos から右に向かって pattern を検索し、 最初に見つかった部分文字列の左端のインデックスを返します。 見つからなければ nil を返します。
...表現で指定します。
pos が負の場合、文字列の末尾から数えた位置から探索します。
@param pattern 探索する部分文字列または正規表現
@param pos 探索を開始するインデックス
//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
@see String#byteindex... -
Regexp
# match(str , pos = 0) -> MatchData | nil (23.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...s << m[0] } # => ["oo"]
/((.)\2)/.match("bar") {|m| results << m[0] } # => nil
results # => ["oo"]
//}
@param str 文字列を指定します。str との正規表現マッチを行います。
@param pos 整数を指定します。マッチの開始位置を pos から行うよう制御できま......に失敗した場合、
nil.captures を呼び出そうとして例外 NoMethodError が発生して
しまいます。
//emlist[例][ruby]{
foo, bar, baz = /(foo)(bar)(baz)/.match("foobar").captures
# => -:1: undefined method `captures' for nil:NilClass (NoMethodError)
//}
@see Regexp#match?... -
Regexp
# match(str , pos = 0) {|m| . . . } -> object | nil (23.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...s << m[0] } # => ["oo"]
/((.)\2)/.match("bar") {|m| results << m[0] } # => nil
results # => ["oo"]
//}
@param str 文字列を指定します。str との正規表現マッチを行います。
@param pos 整数を指定します。マッチの開始位置を pos から行うよう制御できま......に失敗した場合、
nil.captures を呼び出そうとして例外 NoMethodError が発生して
しまいます。
//emlist[例][ruby]{
foo, bar, baz = /(foo)(bar)(baz)/.match("foobar").captures
# => -:1: undefined method `captures' for nil:NilClass (NoMethodError)
//}
@see Regexp#match?... -
String
# index(pattern , pos = 0) -> Integer | nil (22.0) -
文字列のインデックス pos から右に向かって pattern を検索し、 最初に見つかった部分文字列の左端のインデックスを返します。 見つからなければ nil を返します。
...表現で指定します。
pos が負の場合、文字列の末尾から数えた位置から探索します。
@param pattern 探索する部分文字列または正規表現
@param pos 探索を開始するインデックス
//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... -
String
# rindex(pattern , pos = self . size) -> Integer | nil (22.0) -
文字列のインデックス pos から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のインデックスを返します。 見つからなければ nil を返します。
...ら探索を始める
# ing
# ing # 左にずらしていってここで見つかる
//}
@param pattern 探索する部分文字列または正規表現
@param pos 探索を始めるインデックス
//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... -
Regexp
# match(str , pos = 0) -> MatchData | nil (17.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...s << m[0] } # => ["oo"]
/((.)\2)/.match("bar") {|m| results << m[0] } # => nil
results # => ["oo"]
//}
@param str 文字列を指定します。str との正規表現マッチを行います。
@param pos 整数を指定します。マッチの開始位置を pos から行うよう制御できま... -
Regexp
# match(str , pos = 0) {|m| . . . } -> object | nil (17.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...s << m[0] } # => ["oo"]
/((.)\2)/.match("bar") {|m| results << m[0] } # => nil
results # => ["oo"]
//}
@param str 文字列を指定します。str との正規表現マッチを行います。
@param pos 整数を指定します。マッチの開始位置を pos から行うよう制御できま... -
String
# match(regexp , pos = 0) -> MatchData | nil (11.0) -
regexp.match(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match を参照してください。
...('h.ge', 1) # => #<MatchData "hige">
//}
//emlist[例: ブロックを指定した場合][ruby]{
'hello'.match('(.)\1'){|e|"match #{$1}"} # => "match l"
'hello'.match('xx'){|e|"match #{$1}"} # マッチしないためブロックは実行されない
//}
@see Regexp#match, Symbol#match......h('h.ge', 1) # => #<MatchData "hige">
//}
//emlist[例: ブロックを指定した場合][ruby]{
'hello'.match('(.)\1'){|e|"match #{$1}"} # => "match l"
'hello'.match('xx'){|e|"match #{$1}"} # マッチしないためブロックは実行されない
//}
@see Regexp#match, Symbol#match... -
String
# match(regexp , pos = 0) {|m| . . . } -> object (11.0) -
regexp.match(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match を参照してください。
...('h.ge', 1) # => #<MatchData "hige">
//}
//emlist[例: ブロックを指定した場合][ruby]{
'hello'.match('(.)\1'){|e|"match #{$1}"} # => "match l"
'hello'.match('xx'){|e|"match #{$1}"} # マッチしないためブロックは実行されない
//}
@see Regexp#match, Symbol#match...