別のキーワード
種類
- 文書 (24)
- インスタンスメソッド (4)
ライブラリ
- ビルトイン (4)
クラス
- MatchData (4)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - deconstruct (2)
- 正規表現 (12)
検索結果
-
MatchData
# captures -> [String] (18119.0) -
$1, $2, ... を格納した配列を返します。
...応する要素は 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, d:spec/pattern_matching#matching_non_primitive_objects... -
MatchData
# deconstruct -> [String] (3019.0) -
$1, $2, ... を格納した配列を返します。
...応する要素は 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, d:spec/pattern_matching#matching_non_primitive_objects... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (18.0) -
1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))
...l/Object#marshal_load>)) [new]
: ((<Marshal/Object#marshal_dump>)) [new]
追加 ((<ruby-dev:21016>))
=== MatchData
: ((<MatchData#captures|MatchData/captures>)) [new]
追加。((<RCR#139>))
: ((<MatchData#select|MatchData/select>)) [new]
((<MatchData>)) は、Enumerable ではありま......>)) [obsolete]
: ((<組み込み変数/$;>)) [compat]
: ((<組み込み変数/$-F>)) [compat]
: ((<Rubyの起動/-F((*regexp*))>)) [compat]
pattern として正規表現でなく文字列を指定したとき、それを正規表現にコ
ンパイルせず文字列そのものをパタ... -
正規表現 (18.0)
-
正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references
...続けて書くことができます。
//emlist[][ruby]{
# The pattern below matches a vowel followed by 2 word characters:
# 'aen'
/[aeiou]\w{2}/.match("Caenorhabditis elegans") #=> #<MatchData "aen">
# Whereas the following pattern matches a vowel followed by a word
# character, twice, i.e. <tt>......+ ){0}
(?<content> [^<&]+ (\g<element> | [^<&]+)* ){0}
(?<etag> </ \k<name+1> >){0}
\g<element>
__REGEXP__
r.match('<foo>f<bar>bbb</bar>f</foo>').captures
# => ["<foo>f<bar>bbb</bar>f</foo>", "<bar>", "bar", "f<bar>bbb</bar>f", "</foo>"]
//}
最左位置での再帰呼び出しは禁止されてい...