skip(p1)
public
Attempts to skip over the given
pattern beginning with the scan pointer. If it matches, the scan pointer is advanced to the end of
the match, and the length of the match is returned. Otherwise,
nil is returned.
It’s similar to #scan, but without returning the matched string.
s = StringScanner.new('test string')
p s.skip(/\w+/)
p s.skip(/\w+/)
p s.skip(/\s+/)
p s.skip(/\w+/)
p s.skip(/./)
Show source
/*
* call-seq: skip(pattern)
*
* Attempts to skip over the given +pattern+ beginning with the scan pointer.
* If it matches, the scan pointer is advanced to the end of the match, and the
* length of the match is returned. Otherwise, +nil+ is returned.
*
* It's similar to #scan, but without returning the matched string.
*
* s = StringScanner.new('test string')
* p s.skip(/\w+/) # -> 4
* p s.skip(/\w+/) # -> nil
* p s.skip(/\s+/) # -> 1
* p s.skip(/\w+/) # -> 6
* p s.skip(/./)
*
*/
static VALUE
strscan_skip(VALUE self, VALUE re)
{
return strscan_do_scan(self, re, 1, 0, 1);
}