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
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Newlines included in bracket negation
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password