On 2007-03-25, David Morton <mortonda / dgrmm.net> wrote: > > > On Mar 24, 2007, at 4:30 PM, Brian Candler wrote: >> >> For instance: in Perl, /^abc$/ matches only the string "abc". This >> is not >> true in Ruby (although it *is* a valid regexp). To get the same >> behaviour in >> Ruby, you need to write /\Aabc\z/ > > ? > > I don't follow... $ irb irb(main):001:0> "\nabc\n" =~ /^abc$/ => 1 irb(main):002:0> "\nabc\n" =~ /\Aabc\z/ => nil irb(main):003:0> In Ruby ^, $ match the beginning and end of a line, whereas \A, \z match the beginning and end of the whole string. This is not the same thing for multiline strings. In Perl, ^, $, \A, \z behave as Ruby's \A, \z, unless you specify the m modifier to your regexp, in which case they all behave as they do in Ruby. From "perldoc perlre": m Treat string as multiple lines. That is, change "^" and "$" from matching the start or end of the string to matching the start or end of any line anywhere within the string. Regards, Jeremy Henty