[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: word boundary \b (regular expression) in Lua
- From: "Aaron Brown" <aaron-lua@...>
- Date: Tue, 29 Mar 2005 14:18:07 -0500
Hu Zhe wrote:
> However, it seems still not a look-around. It eats up the
> " " between words.
return (string.gsub(Str, "(%W*)(%w)(%w*)(%W)",
function(LeadSpace, FirstLetter, Rest, TrailSpace)
return LeadSpace .. string.upper(FirstLetter) .. Rest
end)) -- function
end -- Capitalize
It grabs leading whitespace (if any), the first letter of a
word, the rest of the letters in the word (if any), and
trailing whitespace (if any), and returns exactly what it
grabbed except with the first letter capitalized.