3件ヒット
[1-3件を表示]
(0.089秒)
検索結果
-
MatchData
# captures -> [String] (63643.0) -
$1, $2, ... を格納した配列を返します。
$1, $2, ... を格納した配列を返します。
MatchData#to_a と異なり $& を要素に含みません。
グループにマッチした部分文字列がなければ対応する要素は nil になります。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["foobar", "foo", "bar", nil]
p $~.captures # => ["foo", "bar", nil]
//}
@see MatchData#to_a, MatchData#named_captures -
MatchData
# to _ a -> [String] (9322.0) -
$&, $1, $2,... を格納した配列を返します。
$&, $1, $2,... を格納した配列を返します。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["foobar", "foo", "bar", nil]
//}
@see MatchData#captures -
正規表現 (265.0)
-
正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references
...る文字列を含まない任意の文字列にマッチします。
(Ruby 2.4.1 で更新された Onigmo に含まれる機能のため、Ruby 2.4.0 では使えません。)
例えば (?~abc) は "", "ab", "aab", "abb", "ccdd" などにはマッチしますが、
"abc", "aabc", "ccabcdd" など...