Why is regexp "\Amax_repeats=(\d+)" not equal to "^max_repeats=([0-9]+)"?

It certainly does help, now I finally understand what went wrong. Thank you
very much for your help Simon, and also for showing me how to check things
out with irb. (And also, everyone else who answered my question: thank you
very much.)

Martin

···

Simon Strandgaard neoneye@adslhome.dk wrote:

Watch out about escaping inside double quoted strings…
observe the difference

irb(main):001:0> re = Regexp.new(“\Ax”)
=> /Ax/
irb(main):002:0> re.match(“xxx”).to_a
=>
irb(main):003:0> re = Regexp.new(‘\Ax’)
=> /\Ax/
irb(main):004:0> re.match(“xxx”).to_a
=> [“x”]
irb(main):005:0>

Does this help you ?


Ontvang je Hotmail & Messenger berichten op je mobiele telefoon
http://www.msn.nl/communicatie/smsdiensten/hotmailsmsv2/

Martin Elzen wrote:

It certainly does help, now I finally understand what went wrong. Thank
you very much for your help Simon, and also for showing me how to check
things out with irb. (And also, everyone else who answered my question:
thank you very much.)

Just want to add that \A is not 100% equivalent to ^ anyway.

irb(main):001:0> “012\n123” =~ /^123/
=> 4
irb(main):002:0> “012\n123” =~ /\A123/
=> nil

···


dave