From: Michael Campbell Date: 2002-11-16T06:19:16+09:00 Subject: Re: Regexp: What does //o do? > Yes. It's not completely clear to me when it will be recompiled > and when it won't be. Above it is not. Below it is. > > irb(main):001:0> s="a" > "a" > irb(main):002:0> /#{s}/o > /a/ > irb(main):003:0> s="b" > "b" > irb(main):004:0> /#{s}/o > /b/ This is 2 different regex's, even though they evaluate to the same, so each one is compiled once. (2 different spots in the source code) > > irb(main):016:0> def foo(s) > irb(main):017:1> re = /#{s}/o > irb(main):018:1> p re > irb(main):019:1> re = nil > irb(main):020:1> end > nil > irb(main):021:0> foo("a") > /a/ > nil > irb(main):022:0> foo("b") > /a/ > nil > > and I'm confused even more. That's the SAME regex (same spot in the source code) used twice. Your first example was 2 different regex's, used once each. ===== -- Yahoo IM: michael_s_campbell __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - Let the expert host your site http://webhosting.yahoo.com