check

check(pattern)
Instance Public methods

This returns the value that scan would return, without advancing the scan pointer. The match register is affected, though.

s = StringScanner.new("Fri Dec 12 1975 14:39")
s.check /Fri/               # -> "Fri"
s.pos                       # -> 0
s.matched                   # -> "Fri"
s.check /12/                # -> nil
s.matched                   # -> nil

Mnemonic: it âchecksâ to see whether a scan will return a value.

doc_ruby_on_rails
2015-05-16 02:00:46
Comments
Leave a Comment

Please login to continue.