The obvious solution works for me:

irb(main):011:0> line = "^\n"
"^\n"
irb(main):012:0> line =~ /^\^$/ and puts "matches!"
matches!
nil
irb(main):013:0>

    robert


"Jim Freeze" <jim / freeze.org> schrieb im Newsbeitrag
news:20030706190559.A19470 / freeze.org...
> Hi:
>
> I am looking for a regex that will match a line with a single
> carrot:
>
>  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.
>
> What I have done to temporarily solve the problem is to use:
>
> irb(main):012:0> /^[ ^]/ =~ line1.strip
> => 0
> irb(main):011:0> /^[ ^]/ =~ line2.strip
> => nil
>
> Does anyone know how to match '^' at the beginning of a line?
>
> -- 
> Jim Freeze
> ----------
>