From: Brian Candler Date: 2003-07-07T08:01:35+09:00 Subject: Re: Need regex to match "^\n" On Mon, Jul 07, 2003 at 07:55:52AM +0900, Jim Freeze wrote: > Hi: > > I am looking for a regex that will match a line with a single > carrot: or caret :-) > line = "^\n" > > However, the obvious does not seem to work: > > > irb(main):001:0> line1 = "^\n" > => "^\n" > irb(main):002:0> line2 = "fred" > => "fred" > irb(main):003:0> /^^/ =~ line1 > => 0 > irb(main):004:0> /^^/ =~ line2 > => 0 > > Using /^\^/ gives an error. This looks like an irb-ism. I get the same as you within irb, but within real code: $ cat x.rb line1 = "^\n" line2 = "fred" p line1 =~ /^\^/ p line2 =~ /^\^/ $ ruby x.rb 0 nil $ ruby -v ruby 1.6.8 (2002-12-24) [i386-freebsd4.8] Regards, Brian.