From: "Hal E. Fulton" Date: 2003-08-09T09:26:40+09:00 Subject: Re: =~ obsolete? ----- Original Message ----- From: "Martin Weber" To: "ruby-talk ML" Sent: Friday, August 08, 2003 7:17 PM Subject: Re: =~ obsolete? > > Why do you need or want string-string as opposed > > to string-regex? Not a flame, just a question. > > > > Dunno, maybe because your (mmv, too) principle of least surprise (yes yes > I'm not argueing based on it, just offering a view!) told you that finding > a substring in a string doesn't need regexes which smell like being awfully > slower than plain string searches and the hope that > > string =~ string > > is something like > > string[string] > > At least that's why I'd try to use it (if not someone recently pointed out > string[string] (again!))... But that's not the same thing... "abc" =~ "c" # 2 (index) "abc"["c"] # "c" But more importantly, the second string is not a substring; it's really a regex stored in a string: "abc" =~ ".." # 0 "abc"[".."] # nil Perhaps the rationale for the obsolescence is that you shouldn't pretend to be using a string when you're really using a regex. Hal -- Hal Fulton hal9000@hypermetrics.com