Difference between ruby StringScanner post_match and rest?
Posted
by
zhon
on Stack Overflow
See other posts from Stack Overflow
or by zhon
Published on 2013-11-08T15:51:34Z
Indexed on
2013/11/08
15:53 UTC
Read the original article
Hit count: 153
What is the difference between ruby's StringScanner#post_match
and StringScanner#rest
?
scanner = StringScanner.new('Say hello to...')
scanner.scan(/\w+/) #=> 'Say'
scanner.scan(/\s+/) #=> ' '
scanner.rest #=> 'hello to...'
scanner.post_match #=> 'hello to...'
scanner.rest.class #=> String
scanner.post_match.class #=> String
I don't see a difference. It seems like both return a string containing everything after the match.
© Stack Overflow or respective owner