Chapter III · The standard library / Lesson 15 of 27

Strings & patterns

You'll learn: Format, slice, and concatenate strings, then capture matches with gmatch and gsub.

.. concatenates, #s is byte length (not codepoints), string.format is printf. Patterns are *not* regex — %a letters, %d digits, %s spaces, . any, %p punctuation. Quantifiers: * 0+, + 1+, ? optional, - shortest match. gmatch yields each match; gsub rewrites with a string or function.

strings.lua
Output idle
Hit Run to execute.
Try it: Use gsub with a function replacement to capitalise every word: "hello there""Hello There". Hint: pattern (%a)(%a*).