~()
public
Match—Matches rxp against the contents of $_.
Equivalent to rxp =~ $_.
$_ = "input data"
~ /at/
Show source
/*
* call-seq:
* ~ rxp => integer or nil
*
* Match---Matches <i>rxp</i> against the contents of <code>$_</code>.
* Equivalent to <code><i>rxp</i> =~ $_</code>.
*
* $_ = "input data"
* ~ /at/
*/
VALUE
rb_reg_match2(re)
VALUE re;
{
long start;
VALUE line = rb_lastline_get();
if (TYPE(line) != T_STRING) {
rb_backref_set(Qnil);
return Qnil;
}
start = rb_reg_search(re, line, 0, 0);
if (start < 0) {
return Qnil;
}
return LONG2FIX(start);
}