Download Firefox: WindowsMac OS X
logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: Possible Regexp documentation bug: msg#00003

Subject: Re: Possible Regexp documentation bug
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?

Cheers, Chris.
--
_____ __     _
\  __/ / ,__(_)_  | Chris Wilson <0000 at qwirx.com> - Cambs UK |
/ (_/ ,\/ _/ /_ \ | Security/C/C++/Java/Perl/SQL/HTML Developer |
\ _/_/_/_//_/___/ | We are GNU-free your mind-and your software |

Attachment: ruby-regexp.patch
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>