On 16 February 2011 03:41, Rob Biedenharn <[email protected]> wrote:
>
> On Feb 15, 2011, at 10:12 PM, Keith Raymond 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'.

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

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to