I tried
assert_match(/bc/x, “ab cd”)
But it fails…
Try: assert_match(/b c/x, “abcd”)
that works… but
assert_match(/b \nc/x, “abcd”)
fails ?
programming-ruby says that newlines will be ignored?
I think it’s only literal newlines – so that if you want to actually
match a newline, there’s still a way to do it. (And since the idea
behind /x is to increase whitespace and readability, there’s not much
advantage skipping over “\n” Here’s an example with a literal
newline:
Feeding the same string into // and into Regexp.new,
yields to different results. A bit inconsist…
def test_option_extended3
# ignoring newline
re = Regexp.new("b\nc", Regexp::EXTENDED)
assert_match(re, "abcd")
end
def test_option_extended4
# does not ignore newline... makes no sense?
assert_no_match(/b\nc/, "abcd")
end
Feeding the same string into // and into Regexp.new,
yields to different results. A bit inconsist…
inconsistent<<
def test_option_extended3
# ignoring newline
re = Regexp.new(“b\nc”, Regexp::EXTENDED)
assert_match(re, “abcd”)
end
def test_option_extended4
# does not ignore newline… makes no sense?
assert_no_match(/b\nc/x, "abcd")
I forgot the ‘x’ ^^^
end
Just my thought
revision 0.2: spell correction.
···
On Wed, 08 Oct 2003 16:51:52 +0200, Simon Strandgaard wrote: