According to the docs, all Lua repetition operators only work on single characters, so you can match
string.match('123', '1?(%d+)') -- returns 23
but cannot match multi-character strings:
string.match('123', '(12)?(%d+)') -- want this to return 3
The docs say it's possible through "multiple patterns and custom logic", but I don't know what that means. Can someone offer a way to pattern match the above? Basically, 12
should be optionally matched all-or-nothing, and return the remainder of the digit string.