From: Rick DeNatale Date: 2009-09-20T13:07:31+09:00 Subject: Re: Regexp question difference between ^ and \A On Sat, Sep 19, 2009 at 9:39 PM, Hunt Jon wrote: > Hi > > I'm trying to find good use examples to show a difference > between ^ and \A in Ruby regular expressions. > > \A is for beginning of a string > ^ beginning of a line or string > > As a regular expression runs one line by line (if I'm correct), > I think both are the same. No you are not correct, and they aren't the same: irb(main):001:0> /\Axyzzy/ =~ "xyzzy" => 0 irb(main):002:0> /\Axyzzy/ =~ "abc\nxyzzy" => nil irb(main):003:0> /^xyzzy/ =~ "xyzzy" => 0 irb(main):004:0> /^xyzzy/ =~ "abc\nxyzzy" => 4 -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale