instance method StringScanner#matched?

matched? -> bool[permalink][rdoc][edit]

前回のマッチが成功していたら true を、失敗していたら false を返します。



require 'strscan'

s = StringScanner.new('test string')
s.matched?    # => false
s.scan(/\w+/) # => "test"
s.matched?    # => true
s.scan(/\w+/) # => nil
s.matched?    # => false
s.scan(/\s+/) # => " "
s.matched?    # => true