In article <200306131529.h5DFTNs29165 / moulon.inra.fr>,
ts  <decoux / moulon.inra.fr> wrote:
>>>>>> "M" == Mike Stok <mike / ratdog.stok.co.uk> writes:
>
>>>> 'mike stok' =~ /^(?i-mx:mike) (?i-mx:stok)$/
>M> => nil
>
> Can you try this (1.6.8)
>
>pigeon% diff -u regex.c.old regex.c
>--- regex.c.old 2003-06-13 17:16:18.000000000 +0200
>+++ regex.c     2003-06-13 17:16:51.000000000 +0200
>@@ -1011,6 +1011,7 @@
>       break;
> 
>     case duplicate:
>+    case option_set:
>       p++;
>       break;
> 
>@@ -1036,7 +1037,6 @@
>     case push_dummy_failure:
>     case start_paren:
>     case stop_paren:
>-    case option_set:
>       break;
> 
>     case charset:
>pigeon%
> 
>pigeon% ./ruby -e 'p ("mike stok" =~ /^(?i-mx:mike) (?i-mx:stok)$/)'
>0
>pigeon% 

This works well but seems to break (under 1.8.0) if I use a trivial
character class.  As a test:

#!/usr/bin/env ruby

require 'test/unit'

class TC_RegExInterpolate < Test::Unit::TestCase
  def test_simple
    m    = /mike/       # case sensitive
    m_i  = /mike/i      # case insensitive
    m_c  = /[Mm]ike/    # char class - allow upper or lower M
    m_c2 = /[M\-m]ike/  # char class - escaped - 

    assert_nil(     'Mike' =~ /#{m}/,    'fail with case sensitive')

    assert_equal(0, 'Mike' =~ /#{m_i}/,  'match with case insensitive (Mike)')
    assert_equal(0, 'mIke' =~ /#{m_i}/,  'match with case insensitive (mIke)')

    assert_equal(0, 'Mike' =~ /#{m_c}/,  'match with char class (Mike)')
    assert_nil(     'mIke' =~ /#{m_c}/,  'fail with char class (mIke)')
    assert_equal(0, 'Mike' =~ /#{m_c}/,  'match with char class (Mike)')

    assert_equal(0, '-ike' =~ /#{m_c2}/, 'match with char class 2 (-ike)')
  end
end

I get this output:

Started
F
Finished in 0.000917 seconds.
 
  1) Failure!!!
test_simple(TC_RegExInterpolate) [regex.rb:15]:
match with char class (Mike).
<0> expected but was
<nil>
    
1 tests, 4 assertions, 1 failures, 0 errors

Mike

-- 
mike / stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       | GPG PGP Key      1024D/059913DA 
mike / exegenix.com                  | Fingerprint      0570 71CD 6790 7C28 3D60
http://www.exegenix.com/           |                  75D2 9EC4 C1C0 0599 13DA