L
Luca Pireddu
Hi all. I have just started playing with Ruby and I'm stuck on something. Is
there some trick to modify the casefold attribute of a Regexp object after
it's been instantiated?
The best idea I've had is the following:
irb(main):001:0> a = Regexp.new('a')
=> /a/
irb(main):002:0> aA = Regexp.new(a.to_s, Regexp::IGNORECASE)
=> /(?-mix:a)/i
But it doesn't seem to work:
irb(main):003:0> a =~ 'a'
=> 0
irb(main):004:0> a =~ 'A'
=> nil
irb(main):005:0> aA =~ 'a'
=> 0
irb(main):006:0> aA =~ 'A'
=> nil
Something I don't understand is happening here. Where did the 'i' go on line
14?
irb(main):013:0> aA = Regexp.new(a.to_s, Regexp::IGNORECASE)
=> /(?-mix:a)/i
irb(main):014:0> aA.to_s
=> "(?-mix:a)"
irb(main):015:0>
I'm using Ruby 1.8.2 (2004-08-24) [i386-linux], irb 0.9(02/07/03) on Debian.
Thanks in advance!
Luca
there some trick to modify the casefold attribute of a Regexp object after
it's been instantiated?
The best idea I've had is the following:
irb(main):001:0> a = Regexp.new('a')
=> /a/
irb(main):002:0> aA = Regexp.new(a.to_s, Regexp::IGNORECASE)
=> /(?-mix:a)/i
But it doesn't seem to work:
irb(main):003:0> a =~ 'a'
=> 0
irb(main):004:0> a =~ 'A'
=> nil
irb(main):005:0> aA =~ 'a'
=> 0
irb(main):006:0> aA =~ 'A'
=> nil
Something I don't understand is happening here. Where did the 'i' go on line
14?
irb(main):013:0> aA = Regexp.new(a.to_s, Regexp::IGNORECASE)
=> /(?-mix:a)/i
irb(main):014:0> aA.to_s
=> "(?-mix:a)"
irb(main):015:0>
I'm using Ruby 1.8.2 (2004-08-24) [i386-linux], irb 0.9(02/07/03) on Debian.
Thanks in advance!
Luca