[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A stupid question
- From: Roberto Ierusalimschy <rieru@...>
- Date: Fri, 11 Jan 2002 10:17:20 -0600 (CST)
On Fri, 11 Jan 2002, Enrico Colombini wrote:
> I have to change a whole word (s) with another word (sh) in a string
> (line), using gsub, but I can't find a simple way to do it.
>
> Suppose the first word (s) is "the"; I want to change every occurrence of
> "the" but not to change the "the" in "theory", "atheist" or "lithe".
Another solution is like this:
line = ' '..line..' '
line = gsub(line, '(%W)'..s..'(%W)', '%1'..sh..'%2') -- in the middle
line = strsub(line, 2, -2)
-- Roberto