instance method StringScanner#post_match

post_match -> String | nil[permalink][rdoc][edit]

前回マッチを行った文字列のうち、マッチしたところよりも後ろの部分文字列を返します。前回のマッチが失敗していると常に nil を返します。



require 'strscan'

s = StringScanner.new('test string')
s.post_match  # => nil
s.scan(/\w+/) # => "test"
s.post_match  # => " string"
s.scan(/\w+/) # => nil
s.post_match  # => nil
s.scan(/\s+/) # => " "
s.post_match  # => "string"
s.scan(/\w+/) # => "string"
s.post_match  # => ""
s.scan(/\w+/) # => nil
s.post_match  # => nil