401件ヒット
[201-300件を表示]
(0.033秒)
クラス
- BasicObject (33)
- Data (22)
- IO (33)
- MatchData (268)
- Proc (6)
- Regexp (11)
-
RubyVM
:: InstructionSequence (9) - String (11)
- Symbol (8)
キーワード
- << (6)
- == (13)
- [] (44)
- begin (11)
- byteoffset (4)
- captures (11)
- deconstruct (2)
-
deconstruct
_ keys (2) - end (11)
- eql? (13)
- fdatasync (11)
- hash (13)
- inspect (13)
-
instance
_ eval (22) - length (11)
- match (30)
- members (2)
-
method
_ missing (11) -
named
_ captures (11) - names (11)
- offset (22)
-
post
_ match (11) -
pre
_ match (11) - regexp (11)
- seek (11)
- size (11)
- string (11)
- sysseek (11)
-
to
_ a (11) -
to
_ binary (9) -
to
_ h (4) -
to
_ s (13) -
values
_ at (11) - with (2)
検索結果
先頭5件
-
MatchData
# offset(n) -> [Integer , Integer] | [nil , nil] (3003.0) -
n 番目の部分文字列のオフセットの配列 [start, end] を返 します。
...lf.begin(n), self.end(n) ]
//}
と同じです。n番目の部分文字列がマッチしていなければ
[nil, nil] を返します。
@param n 部分文字列を指定する数値
@raise IndexError 範囲外の n を指定した場合に発生します。
@see MatchData#begin, MatchData#end... -
MatchData
# offset(name) -> [Integer , Integer] | [nil , nil] (3003.0) -
name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返 します。
...('year') # => [0, 4]
p $~.offset(:year) # => [0, 4]
p $~.offset('month') # => [5, 6]
p $~.offset(:month) # => [5, 6]
p $~.offset('day') # => [nil, nil]
p $~.offset('century') # => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#begin, MatchData#end......0, 4]
p $~.offset(:year) # => [0, 4]
p $~.offset('month') # => [5, 6]
p $~.offset(:month) # => [5, 6]
p $~.offset('day') # => [nil, nil]
p $~.offset('century') # => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#begin, MatchData#end, MatchData#offset... -
MatchData
# post _ match -> String (3003.0) -
マッチした部分より後ろの文字列を返します($'と同じ)。
...マッチした部分より後ろの文字列を返します($'と同じ)。
//emlist[例][ruby]{
/(bar)(BAZ)?/ =~ "foobarbaz"
p $~.post_match # => "baz"
//}
@see MatchData#pre_match... -
MatchData
# pre _ match -> String (3003.0) -
マッチした部分より前の文字列を返します($`と同じ)。
...マッチした部分より前の文字列を返します($`と同じ)。
//emlist[例][ruby]{
/(bar)(BAZ)?/ =~ "foobarbaz"
p $~.pre_match # => "foo"
//}
@see MatchData#post_match... -
MatchData
# regexp -> Regexp (3003.0) -
自身の元になった正規表現オブジェクトを返します。
自身の元になった正規表現オブジェクトを返します。
//emlist[例][ruby]{
m = /a.*b/.match("abc")
m.regexp # => /a.*b/
//} -
MatchData
# size -> Integer (3003.0) -
部分文字列の数を返します(self.to_a.size と同じです)。
部分文字列の数を返します(self.to_a.size と同じです)。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.size # => 4
//} -
MatchData
# string -> String (3003.0) -
マッチ対象になった文字列の複製を返します。
マッチ対象になった文字列の複製を返します。
返す文字列はフリーズ(Object#freeze)されています。
//emlist[例][ruby]{
m = /(.)(.)(\d+)(\d)/.match("THX1138.")
m.string # => "THX1138."
//} -
MatchData
# to _ a -> [String] (3003.0) -
$&, $1, $2,... を格納した配列を返します。
...$&, $1, $2,... を格納した配列を返します。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["foobar", "foo", "bar", nil]
//}
@see MatchData#captures... -
MatchData
# to _ s -> String (3003.0) -
マッチした文字列全体を返します。
...マッチした文字列全体を返します。
//emlist[例][ruby]{
/bar/ =~ "foobarbaz"
p $~ # => #<MatchData:0x401b1be4>
p $~.to_s # => "bar"
//}... -
MatchData
# values _ at(*index) -> [String] (3003.0) -
正規表現中の n 番目の括弧にマッチした部分文字列の配列を返します。
正規表現中の n 番目の括弧にマッチした部分文字列の配列を返します。
0 番目は $& のようにマッチした文字列全体を表します。
@param index インデックスを整数またはシンボル(名前付きキャプチャの場合)で 0 個以上指定します。
//emlist[例][ruby]{
m = /(foo)(bar)(baz)/.match("foobarbaz")
# same as m.to_a.values_at(...)
p m.values_at(0, 1, 2, 3, 4) # => ["foobarbaz", "foo", "bar", "baz", nil]
p m...