From: Austin Ziegler Date: 2005-11-24T02:38:03+09:00 Subject: Re: String#to_rx ? On 11/23/05, Trans wrote: > Austin Ziegler wrote: > > I disagree that either #to_re or #to_rx would be a good name for this > > construct. I think that it would be better to have a method on Regexp > > itself (a new, alternative constructor) that does this. Maybe: > > > > Regexp.compile_escaped(str) > > The problem here is largely one of brevity. Who wants to type all that > when #to_re will do? Because neither #to_re nor #to_rx are expressive enough. As such, they don't belong in the core. > I think even more usful though would just be a method on String that > does the Regexp escaping. I had been using my own small Kernel method > #resc(str) for this, but now I see it would be much more useful as a > String method: > > /^#{foo.resc}/ =~ bar > > All things being the same, I'll put that in the next verison of Facets. Another name without expressiveness. #escape_regexp would be better. But that doesn't suit your apparent need for brevity. Maybe #regesc, but I would still oppose its inclusion in the core, so it really does probably belong in Facets, where I don't have to even care that it exists. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca