Game Development Reference
In-Depth Information
Pattern
A pattern is a sequence of pattern items. A caret ( ^ ) indicates the beginning of a pattern and a $ symbol
specifies the end of the pattern. At other positions, they have no special meaning, but only represent
themselves.
Capture
A pattern can contain subpatterns enclosed in parentheses; these are described as captures . When
a match succeeds, the substrings that the match captures are stored (captured) for further use.
Captures are numbered according to their left parentheses. In the pattern "(a*(.)%w(%s*))" , the part
"(a*(.)%w(%s*))" is stored as the first capture, the character matching the
. ) is stored as the second, and the part matching the %s* is stored as the third.
As described previously, the function that converts strings to uppercase is very simple. Here's a
function that makes it even simpler to use:
function upper(theString)
return string.upper(theString)
end
Converting Strings to Lowercase
This is similar to the previous function.
function lower(theString)
return string.lower(theString)
end
Converting Strings to Title Case
This function converts a string to title case, in which the first character of all words is capitalized:
function title_case(theString)
return (theString:gsub("^%a", string.upper):gsub("%s+%a", string.upper))
end
 
Search WWH ::




Custom Search