From: Rob Biedenharn Date: 2008-04-20T04:29:35+09:00 Subject: Re: line breaks in multiline regexp Oops! If I have the "signed" option in Mail.app, the response doesn't make it sometimes. -Rob On Apr 18, 2008, at 9:25 AM, Andrey Chaschev wrote: > Hi! I really want to know how to denote line breaks in multiline > regexp. > > The problem is that \s is not only a line break. > > I.e. how to parse this in a general way? > > s=< a loooong-loooong text with > MANY spaces and *single* line breaks > followed by three empty lines > > > this line must be detached from the previous > HERE > > Thanks in advance! Just use \n to match the literal newline. The m option just changes when \n is matched by a wildcard. irb> s.match(/(.*\n\n\n)/m).captures => ["a loooong-loooong text with\nMANY spaces and *single* line breaks\nfollowed by three empty lines\n\n\n"] irb> s =~ /(.*\n\n\n)/m => 0 irb> $1 => "a loooong-loooong text with\nMANY spaces and *single* line breaks\nfollowed by three empty lines\n\n\n" Without the m irb> s =~ /(.*\n\n\n)/ => 69 irb> $1 => "followed by three empty lines\n\n\n" You can still have \n, but the .* doesn't match all the previous characters. -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com