From: "Berger, Daniel" Date: 2005-09-14T04:07:15+09:00 Subject: Re: Surprising Regexp Behavior > -----Original Message----- > From: Ara.T.Howard [mailto:Ara.T.Howard@noaa.gov] > Sent: Tuesday, September 13, 2005 12:53 PM > To: ruby-talk ML > Subject: Re: Surprising Regexp Behavior > > > On Wed, 14 Sep 2005, James Edward Gray II wrote: > > > On Sep 13, 2005, at 1:46 PM, Berger, Daniel wrote: > > > >> In the former, sub != gsub. In the latter, you need > multi-line mode > >> because of the "\n\n": > >> > >> # Without /m > >> irb(main):026:0> html =~ /

(.*?)<\/p>(.*)/ > >> => 0 > >> irb(main):027:0> $1 > >> => "one" > >> irb(main):028:0> $2 > >> => "" > >> > >> # With /m > >> irb(main):023:0> html =~ /

(.*?)<\/p>(.*)/m > >> => 0 > >> irb(main):024:0> $1 > >> => "one" > >> irb(main):025:0> $2 > >> => "\n\n

two

" > > > > Yep, that's what I was forgetting. Thanks for the lesson. > > thank dave thomas - the pickaxe (html version I) is always > open in my browser > - but far the most oft used page is the one on regex syntax. > it just happend to be open ;-) Also see http://www.zenspider.com/Languages/Ruby/QuickRef.html#10 Thank Ryan Davis. :) Regards, Dan