On 15/07/07, Chris Wilson <chris@xxxxxxxxx> wrote:
On Sun, 15 Jul 2007, Konrad Meyer wrote:
>> "(Regexp.escape) Escapes any characters that would have special meaning in
>> a regular expression. Returns a new escaped string, or self if no
>> characters are escaped. For any string, Regexp.escape(str)=~str will be
>> true."
...
>> I think it would be more accurate to say:
>>
>> "str =~ Regexp.escape(str) will be true."
...
> While =~ is not an operator, it is a method of String and Regexp
> instances, Regexp.escape (from quick irb testing) returns a string.
> And String#=~ expects a Regexp instance, not a string. So I think it
> would be correct to change that to something like `Regexp.escape(str)
> =~ Regexp.new(str) will be true'.
Thanks Konrad and Ryan. Is the attached patch acceptable, documenting both
forms in what I believe is the correct way?
I think the bit after the `and' is excessive. It's not the job of this
method's documentation to clarify that str =~ rxp is the same as rxp
=~ str.
|