matched_size()
public
Returns the size of the most recent match (see #matched), or nil
if there was no recent match.
s = StringScanner.new('test string')
s.check /\w+/ # -> "test"
s.matched_size # -> 4
s.check /\d+/ # -> nil
s.matched_size # -> nil
Show source
/*
* Returns the size of the most recent match (see #matched), or +nil+ if there
* was no recent match.
*
* s = StringScanner.new('test string')
* s.check /\w+/ # -> "test"
* s.matched_size # -> 4
* s.check /\d+/ # -> nil
* s.matched_size # -> nil
*/
static VALUE
strscan_matched_size(VALUE self)
{
struct strscanner *p;
GET_SCANNER(self, p);
if (! MATCHED_P(p)) return Qnil;
return INT2NUM(p->regs.end[0] - p->regs.beg[0]);
}