Ruby 2.6.0 リファレンスマニュアル > ライブラリ一覧 > strscanライブラリ > StringScannerクラス > clear
terminate -> self
[permalink][rdoc]clear -> self
スキャンポインタを文字列末尾後まで進め、マッチ記録を捨てます。
pos = self.string.size と同じ動作です。
require 'strscan'
s = StringScanner.new('test string')
s.scan(/\w+/) # => "test"
s.matched # => "test"
s.pos # => 4
s[0] # => "test"
s.terminate
s.matched # => nil
s[0] # => nil
s.pos # => 11
StringScanner#clear は将来のバージョンで削除される予定です。代わりに StringScanner#terminate を使ってください。