Hi --

On Wed, 10 Jul 2002, Stepan Kasal wrote:

> Hallo,
>
> On Wed, 10 Jul 2002 09:01:11 GMT, Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
> >   Regexp.new_const(s) = Regexp.new(Regexp.quote(s))
>
> I've forgotten about this, sorry.
>
> So I vote for a-c, with an error message saying something like
>
> "use either Regexp.new(s) or Regexp.new(Regexp.quote(s)) to clarify"

Quick reminder, for reference :-)

  sub/gsub

   (a) prohibit string pattern
   (b) string patterns as strings, without converting into regex.

  split

   (c) prohibit string pattern longer than 1.
   (d) string patterns as strings, without converting into regex.

> How many times do people use "error.log" or "error\.log" instead of
> "error\\.log" or /error\.log/ ?

Well... something a lot like that is what started this thread :-)
It's partly a matter of documentation stating that String#split takes
a string or a regex, without (anywhere I've seen) noting that the
string has to be only one character long or else has to follow regex
syntax (because it's really a regex).

I'm not sure what the disadvantage of allowing a string argument is.
It's not mandatory -- you can always use a regex (or even
Regexp.new(s) :-)  -- so allowing strings (without auto-conversion to
regex) doesn't take away any functionality.


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav