On 09/18/2010 12:42 PM, John Smith wrote:
> Hmm it works perfect for what I asked.. but I realized I will probably 
> need it more
> granular. Instead of the first occurrence within a file, the first 
> ocurrence in a line.
> 
> As of now it works, for this  case:
> 
> 1 4
> 1 5
> 1 4
> 1 5
> 
> one four
> 1 5
> 1 4
> 1 5
> 
> However,
> 
> If we have :
> 1 4 1 4 1 5
> 
> it will put
> one four one four one 5
> 
> and I want:
> one four 1 4 1 5
> 
> From here I suppose it would be a matter of working with the line. Is 
> there a command to replace first occurrence of a word in a line with 
> another word?
> 
> Something like:
> 
> line.detect_first_occurrence_and replace("1", one).

The example I sent should do exactly what you're saying here.  Are you
certain that you did not replace the sub method with gsub?  Some of the
examples sent to you by others earlier specified using gsub which will
indeed perform a repeated search/replace over the string being
processed; however, the sub method will only operate once.

-Jeremy