List Info

Thread: Possible Regexp documentation bug




Possible Regexp documentation bug
country flaguser name
United Kingdom
2007-07-15 12:39:56
Hi all,

I think I found a small bug in the description of the
Regexp.escape method 
(http://www.ruby-doc.org/core/classes/Regexp.html#M001216
).

It says:

"(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 the last part is incorrect. The left-hand side of
the =~ operator 
should be a string, the right-hand side should be a regexp.
So if the 
escape method does change anything, the condition will not
hold.

I think it would be more accurate to say:

   "str =~ Regexp.escape(str) will be true."

Is that right? And how should one go about changing the
documentation?

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 |


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )