From: Reimer Behrends Date: 2003-06-30T10:00:35+09:00 Subject: Re: Regexp#options (RCR #43) Daniel Berger (djberg96@yahoo.com) wrote: [...] > # example using longhand > irb(main):001:0> r = > Regexp.new(/\w+/,Regexp::EXTENDED) > (irb):1: warning: flags ignored > => /\w+/ Try Regexp.new("\\w+", Regexp::EXTENDED) There's really only a point to giving flags when you compile a string; if you pass a regular expression, you can already provide the flags. > # example using shorthand > irb(main):002:0> r.options > => 0irb(main):003:0> r = /\w+/xi > => /\w+/ix > irb(main):004:0> r.options > => 3 Regexp#options returns the logical or of all flags. > My guess is that it's returning length + 1, instead of > the options themselves. If my opinion carries any > weight, I would like r.options (using the last > example) to return ["x","i"]. class Regexp def verbose_options opts = options result = [] for i, name in [[IGNORECASE, "i"], [EXTENDED, "x"], [MULTILINE, "m"]] do if (opts & i) != 0 then result << name end end result end end Reimer Behrends