On Tue, Nov 23, 2010 at 4:36 PM, Ammar Ali <ammarabuali / gmail.com> wrote:
> On Tue, Nov 23, 2010 at 4:36 PM, Ruby Nuby <b1st / hotmail.com> wrote:
>
>> irb, Ruby 1.9.1
>>
>> What am I missing here?
>>
>> "b T T W b".match(/(?<!t t|a b) w/i)
>> => nil
>>
>> #The second look-behind is now just a
>> "b T T W b".match(/(?<!t t|a) w/i)
>> => #<MatchData " W">
>>
>> #Regex stays the same, the T T are now in lower case
>> "b t t W b".match(/(?<!t t|a) w/i)
>> => nil
>>
>> #Look-behind only contains the t t condition now and, T T are back to
>> upper case
>> "b T T W b".match(/(?<!t t) w/i)
>> => nil
>
> No bug here. It is doing exactly what you asked: only match a w if it is not
> preceded by 't t'. In all cases the w is preceded by 't t', and in the case
> that did match (?<!t t|a), the w was preceded by a 't t' but not an 'a', as
> you asked, so it did match.

That was an alternative!  If the RX in the lookbehind can match, the
negative lookbehind must fail IMHO.

There is a problem with the match though.  I suspect there is an issue
with case sensitivity propagation

irb(main):009:0> "b T T W b".match(/(?<!t t|a) w/i)
=> #<MatchData " W">
irb(main):010:0> "b T T W b".match(/(?i:<!t t|a) w/i)
=> nil

irb(main):013:0> RUBY_VERSION
=> "1.9.1"
irb(main):014:0> RUBY_PATCHLEVEL
=> 430

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/