[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Newlines included in bracket negation

ara.t.howard

10/27/2007 2:34:00 AM


On Oct 26, 2007, at 3:30 PM, Chris Morris wrote:

> Adding \n inside the brackets fixes it, I just wouldn't expect to
> have to do
> this since I didn't add the multiline mode option.
>
> require 'test/unit'
>
> class TestRE < Test::Unit::TestCase
> def test_newlines
> src = "happy\n\nbirthday"
> assert_equal("hday", src.scan(/h[^x\n]*?day/).to_s)
> end
> end

from memory, 'multiline' affects *only* the behavior of '.' in res
the re

[^x] => 'not x'

simply matches any char that is not 'x' - including newline

it's the same in perl and python iirc

cheers.

a @ http://codeforp...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama