我正在玩,看看如何Regex#to_s
禁用该模式的选项%r/../
。但是对这样的输出感到困惑Regex#to_s
:
irb(main):005:0> %r/ab+c/x.to_s
=> "(?x-mi:ab+c)" #why here -m option has been disabled?
irb(main):006:0> %r/ab+c/i.to_s
=> "(?i-mx:ab+c)" #why here -m option has been disabled?
irb(main):007:0> %r/ab+c/m.to_s
=> "(?m-ix:ab+c)" #why here -i option has been disabled?
irb(main):008:0> %r/ab+c/o.to_s
=> "(?-mix:ab+c)" #why here o option not get into the (...) as the above?
irb(main):009:0> %r/ab+c/.to_s
=> "(?-mix:ab+c)" #why always m,i,x option get into the (...) as the above?
任何人都可以在这里帮助我了解选项开启/关闭的逻辑吗?
Regex#hash
和Regex#quote
方法在 Ruby 1.9.3 中如何工作(任何小代码都可以理解)?