クラス
-
ARGF
. class (11) - Dir (11)
- Regexp (30)
- String (52)
- StringIO (11)
- StringScanner (33)
- Symbol (8)
検索結果
先頭5件
-
ARGF
. class # pos=(n) (21106.0) -
ARGFが開いているファイルのファイルポインタを指定位置に移動します。
...ARGFが開いているファイルのファイルポインタを指定位置に移動します。
@param n 先頭からのオフセットをバイト単位の整数で指定します。
ARGF.pos = 17
ARGF.gets # => "This is line two\n"
@see IO#pos=, ARGF.class#pos... -
StringScanner
# clear -> self (6106.0) -
スキャンポインタを文字列末尾後まで進め、マッチ記録を捨てます。
...return self を返します。
pos = self.string.size と同じ動作です。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.scan(/\w+/) # => "test"
s.matched # => "test"
s.pos # => 4
s[0] # => "test"
s.terminate
s.matched # => nil
s[0]......# => nil
s.pos # => 11
//}
StringScanner#clear は将来のバージョンで削除される予定です。
代わりに StringScanner#terminate を使ってください。... -
StringScanner
# terminate -> self (3106.0) -
スキャンポインタを文字列末尾後まで進め、マッチ記録を捨てます。
...return self を返します。
pos = self.string.size と同じ動作です。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.scan(/\w+/) # => "test"
s.matched # => "test"
s.pos # => 4
s[0] # => "test"
s.terminate
s.matched # => nil
s[0]......# => nil
s.pos # => 11
//}
StringScanner#clear は将来のバージョンで削除される予定です。
代わりに StringScanner#terminate を使ってください。... -
Symbol
# match?(regexp , pos = 0) -> bool (3101.0) -
regexp.match?(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match? を参照してください。
...xp.match?(self, pos) と同じです。
regexp が文字列の場合は、正規表現にコンパイルします。
詳しくは Regexp#match? を参照してください。
例:
:Ruby.match?(/R.../) # => true
:Ruby.match?('Ruby') # => true
:Ruby.match?('Ruby',1) # => false
:Ruby.m......atch?('uby',1) # => true
:Ruby.match?(/P.../) # => false
$& # => nil
@see Regexp#match?, String#match?... -
Dir
# seek(pos) -> self (3100.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
...#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read # => "."
i = d.tell... -
StringIO
# ungetc(str _ or _ int) -> nil (124.0) -
文字列か整数で指定された str_or_int を自身に書き戻します。 nil を返します。
...文字列か整数で指定された str_or_int を自身に書き戻します。
nil を返します。
何回でも書き戻すことが可能です。
現在位置が自身のサイズよりも大きい場合は、自身をリサイズしてから、ch を書き戻します。
@param str_or_int......します。
//emlist[例][ruby]{
require "stringio"
s = StringIO.new("hoge")
s.pos = 1
s.ungetc("H")
p s.string # => "Hoge"
p s.pos # => 0
s = StringIO.new("hoge")
s.pos = 1
s.ungetc("H".ord)
p s.string # => "Hoge"
p s.pos # => 0
s = StringIO.new("hoge")
s.pos = 4
s.ungetc("HOGE")......p s.string # => "hogHOGE"
p s.pos # => 3
s = StringIO.new("hoge")
s.pos = 8
s.ungetc("A")
p s.string # => "hoge\000\000\000A"
p s.pos # => 7
//}... -
String
# match(regexp , pos = 0) -> MatchData | nil (114.0) -
regexp.match(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match を参照してください。
...lf, pos) と同じです。
regexp が文字列の場合は、正規表現にコンパイルします。
詳しくは Regexp#match を参照してください。
//emlist[例: regexp のみの場合][ruby]{
'hello'.match('(.)\1') # => #<MatchData "ll" 1:"l">
'hello'.match('(.)\1')[0] # => "l......l"
'hello'.match(/(.)\1/)[0] # => "ll"
'hello'.match('xx') # => nil
//}
//emlist[例: regexp, pos を指定した場合][ruby]{
'hoge hige hege bar'.match('h.ge', 0) # => #<MatchData "hoge">
'hoge hige hege bar'.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... -
StringScanner
# reset -> self (106.0) -
スキャンポインタを文字列の先頭 (インデックス 0) に戻し、 マッチ記録を捨てます。
...
pos = 0と同じ動作です。
@return self を返します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.scan(/\w+/) # => "test"
s.matched # => "test"
s.pos # => 4
s[0] # => "test"
s.reset
s.matched # => nil
s[0] # => nil
s.... -
Regexp
# match(str , pos = 0) -> MatchData | nil (102.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...トで返し
ます。
マッチしなかった場合 nil を返します。
省略可能な第二引数 pos を指定すると、マッチの開始位置を pos から行
うよう制御できます(pos のデフォルト値は 0)。
//emlist[例][ruby]{
p(/(.).(.)/.match("foobar", 3).captures)......ures) # => ["b", "r"]
//}
pos を指定しても MatchData#offset 等の結果
には影響しません。つまり、
//emlist[][ruby]{
re.match(str[pos..-1])
//}
と
//emlist[][ruby]{
re.match(str, pos)
//}
は異なります。
ブロックを渡すと、マッチした場合に限り MatchDa......ロックの値を返し、マッチしなかった場合は nil を返します。
//emlist[例][ruby]{
results = []
/((.)\2)/.match("foo") {|m| results << m[0] } # => ["oo"]
/((.)\2)/.match("bar") {|m| results << m[0] } # => nil
results # => ["oo"]
//}
@param str 文字列を指定します。s... -
Regexp
# match(str , pos = 0) {|m| . . . } -> object | nil (102.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...トで返し
ます。
マッチしなかった場合 nil を返します。
省略可能な第二引数 pos を指定すると、マッチの開始位置を pos から行
うよう制御できます(pos のデフォルト値は 0)。
//emlist[例][ruby]{
p(/(.).(.)/.match("foobar", 3).captures)......ures) # => ["b", "r"]
//}
pos を指定しても MatchData#offset 等の結果
には影響しません。つまり、
//emlist[][ruby]{
re.match(str[pos..-1])
//}
と
//emlist[][ruby]{
re.match(str, pos)
//}
は異なります。
ブロックを渡すと、マッチした場合に限り MatchDa......ロックの値を返し、マッチしなかった場合は nil を返します。
//emlist[例][ruby]{
results = []
/((.)\2)/.match("foo") {|m| results << m[0] } # => ["oo"]
/((.)\2)/.match("bar") {|m| results << m[0] } # => nil
results # => ["oo"]
//}
@param str 文字列を指定します。s...