From: Michael Campbell Date: 2003-12-24T01:12:55+09:00 Subject: Re: Strings to regexps (non-demanding post :->) James F. Hranicky wrote: > On Fri, 19 Dec 2003 03:12:57 +0900 > Elias Athanasopoulos wrote: > > >>I had this "problem", too. I can't see why Ruby is so verbose on that >>and doesn't interpret foo.gsub[!]("bar", ...) as foo.gsub[!](/bar/, ...) >>automagically... > > > The main reason I like this > > line.match('/usr/local/lib/blah/blah/blah') > > is so I don't have to escape forward slashes: > > line.match(/\/usr\/local\/lib\/blah\/blah/) > > I suppose writing this > > line.match(Regexp.new("/usr/local/lib/blah/blah/blah")) > > works, though a touch less elegant. No biggie, though. Perhaps there's a > better way than that? Don't know if you'd consider this "better", but there's /another/ way... p "foo/bar/baz".match(%r{foo/bar}) __________________________________ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/