Matthew Margolis
9/27/2004 10:59:00 PM
David A. Black wrote:
>Hi --
>
>On Tue, 28 Sep 2004, Matthew Margolis wrote:
>
>
>
>>David A. Black wrote:
>>
>>
>>
>>>Hi --
>>>
>>>On Tue, 28 Sep 2004, David A. Black wrote:
>>>
>>>
>>>
>>>
>>>
>>>> thestring.sub!(/\d{5}/) {|x| "#{x},"}
>>>>
>>>>
>>>>
>>>>
>>>Amendment: as James G. suggested, use gsub! if you have more than one
>>>in one string :-) Also make sure that you have no street numbers with
>>>five digits in a row.
>>>
>>>
>>>David
>>>
>>>
>>>
>>>
>>>
>>Excellent. I didn't know that each returned new objects. Thanks a
>>bunch guys.
>>
>>
>
>Just to clarify: it (each) doesn't always return new objects; it
>depends on the particular case. For example, in the case of
>Array#each, you do get the actual array element. With strings, the
>effect is like splitting the string into lines, i.e., substrings.
>
>
>David
>
>
>
Understood.
-Matt Margolis