Ruby 2.0.0 リファレンスマニュアル > ライブラリ一覧 > strscanライブラリ > StringScannerクラス > matched
matched -> String | nil[permalink][rdoc]前回マッチした部分文字列を返します。 前回のマッチに失敗していると nil を返します。
使用例
s = StringScanner.new('test string')
s.matched # => nil
s.scan(/\w+/) # => "test"
s.matched # => "test"
s.scan(/\w+/) # => nil
s.matched # => nil
s.scan(/\s+/) # => " "
s.matched # => " "