Regular expression not working in Rails

I can't figure out why this regexp isn't working in my rails method. I've been testing it with the the firefox regular expression tester add on and it works there but not in the rails app.

My expression is: /\Q[img['\E/ I'm trying to match: [img['

I am getting an error saying "Early end to regexp" or something like that

I can't figure out why this regexp isn't working in my rails method. I've been testing it with the the firefox regular expression tester add on and it works there but not in the rails app.

My expression is: /\Q[img['\E/ I'm trying to match: [img['

/\[img\['/ =~ "[img['"

=> 0

You need to ecsape the [ characters as they introduce a character set, e.g., [a-z] or [0-9] or even [img] to match any of 'i', 'm', or 'g'.

I am getting an error saying "Early end to regexp" or something like that

-Rob

Rob Biedenharn Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab@GaslightSoftware.com http://GaslightSoftware.com/

It have noticed previously that some regexp engines are clever enough to work out that a mismatched [ does not need to be escaped, which is likely why it appeared to work in FF. I would have thought though that something that purports to be a 'tester' should enforce the rules rigorously.

Colin