[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to capiltalize only the first leter of a string?
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Mon, 25 Feb 2013 13:08:02 +0000
2013/2/25 Kevin Martin <firstname.lastname@example.org>:
> Do a gsub that matches a lowercase first letter and replaces it with the upper cased first character of the string.
> Something like: (don't have ref manual in front of me)
> str:gsub("^%l", str:sub(1):upper())
You can simplify that by passing the string.upper function to gsub,
which will then work with a simpler pattern:
Name = name:gsub("^.", string.upper)