From: Robert Klemme Date: 2008-04-09T22:17:04+09:00 Subject: Re: Ruby multiline regex problem 2008/4/8, Gregg Yows : > Code: > > "
href="http://www.amazon.com/Rails-Recipes/dp/0977616606/ref=pd_sim_b_njs_img_1">testPit > something here Best" > > > Pattern: > > .*?<\/td\s*> > > > I'm trying to match this whole block and use it for further parsing. > This started from an example in Brian Merick's book "Everyday > Scripting..." that had to be modified because amazon has changed their > presentation to tables instead of lists. > > Anyway, the regex works fine as a single-line. as soon as I introduce > this: > > "
href="http://www.amazon.com/Rails-Recipes/dp/0977616606/ref=pd_sim_b_njs_img_1">testPit > something here > > Best" > > it fails. > > When I try this same expression with perl using the //s mode, it works. > I understand Ruby uses //m (multi-line mode in nearly the same fashion > causing newlines to be considered any character, so it should work, > right? Can anyone tell me what I am doing wrong here? Why isn't > "multiline" mode working? Works for me: no match without /m, match with /m: irb(main):004:0> s=%q{
testPit irb(main):006:0' something here Best} => "
testPit\nsomething here Best" irb(main):007:0> s[%r{}] => nil irb(main):008:0> s[%r{}m] => "
testPit\nsomething here Best" irb(main):009:0> Cheers robert -- use.inject do |as, often| as.you_can - without end