unknown wrote:
> On Nov 12, 6:39 pm, James Edward Gray II <ja... / grayproductions.net>
> wrote:
>>
>> If you don't know the contents of the Regexp and thus you call gsub
>> (), you are a much braver programmer than I am!
> 
> You've never used a Regexp variable?  Always a Regexp literal for
> you?  That's why I put a variable there, to make the point that it
> can't just be concatenated.
> 
>> It's clear we just disagree and I've said my peace now.  You win.  ;)
> 
> In my previous post, I did however make a valid argument with a valid
> example, to which you did not respond.


The exchange was great from both sides.

But the point that JGII is making about 're' is not that he prefers 
Regexp literals vs variables! it is that if the regexp variable 
contained an anchor like \A it does not make a lot of sense to call 
gsub... because it would at most match once!

So while we may not know the exact content of the regexp (eg, it is 
provided by another component, etc), it makes sense to think that at 
least we know it is suited to a global replace (if not, what exactly are 
we doing? the whole thing loses any sense).

-- 
Posted via http://www.ruby-forum.com/.