lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>function change (src, find, rep)
>	src = gsub (src, "(%w+)", function (word)
>		if word == %find then
>			return %rep
>		else
>			return word
>		end
>	end)
>	return src
>end
>
>> print(change("the theory abcthedef", "the", "THE"))
>THE theory abcthedef
>
>	Is it what you wanted?

Yes, I think that will do the trick (and it doesn't look too costly in
terms of performance).

Thanks, I see that I have to learn to think more 'functionally'... and
study better the examples in the manual :-)

  Enrico