我正在玩Regex#to_s
禁用選項%r/../
。但是,越來越困惑與此類Regex#to_s
的輸出:與%r /..../ option.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中是如何工作的(任何小代碼都能理解)?
任何人都可以通過回答爲什麼不'o'和爲什麼總是'我,m,x'除了'o'嗎? – DoLoveSky