Strings In Depth14 / 14
Up next

Capture with match

-- parentheses in a pattern capture sub-parts
local date = "2026-09-23"
local year, month, day = string.match(date, "(%d+)-(%d+)-(%d+)")
print(year, month, day)
What you're solving

string.match returns captured groups