Method: Regexp#options
- Defined in:
- re.c
#options ⇒ Integer
Returns an integer whose bits show the options set in self
.
The option bits are:
Regexp::IGNORECASE # => 1
Regexp::EXTENDED # => 2
Regexp::MULTILINE # => 4
Examples:
/foo/. # => 0
/foo/i. # => 1
/foo/x. # => 2
/foo/m. # => 4
/foo/mix. # => 7
Note that additional bits may be set in the returned integer; these are maintained internally in self
, are ignored if passed to Regexp.new, and may be ignored by the caller:
Returns the set of bits corresponding to the options used when creating this regexp (see Regexp::new for details). Note that additional bits may be set in the returned options: these are used internally by the regular expression code. These extra bits are ignored if the options are passed to Regexp::new:
r = /\xa1\xa2/e # => /\xa1\xa2/
r.source # => "\\xa1\\xa2"
r. # => 16
Regexp.new(r.source, r.) # => /\xa1\xa2/
789 790 791 792 793 794 |
# File 're.c', line 789
static VALUE
rb_reg_options_m(VALUE re)
{
int options = rb_reg_options(re);
return INT2NUM(options);
}
|