From: Aldric Giacomoni Date: 2010-01-14T02:32:30+09:00 Subject: Re: Bug with end of string characters in regex? Justin Coyne wrote: > /\A\n\Z/m.match("\n\n") => # > > shouldn't this expression return nil? > > > These both return nil. > /\A\n\Z/m.match("a\n") > /\A\n\Z/m.match("\na") > > > My understanding is that \A and \Z always match at the beginning/end of > the string irrespective of newlines. > > -Justin Check out rubular.com You are asking for: \A # beginning of string \n # newline \Z # end of string And by the way ... "\n" and /\n/ may not be the same, depending on what the regexp wants to do with the backslash! you could try escaping it. What do you want to match? maybe: /A # beginning of string .* # any characters \\n # newline .* # any characters /Z # end of string -- Posted via http://www.ruby-forum.com/.