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

On 16 February 2011 03:41, Rob B. [email protected]
wrote:

irb> /[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’.

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

On Feb 15, 2011, at 10:12 PM, Keith R. wrote:

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[’

irb> /[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 B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/