Cyberience
Cyberience

Reputation: 1088

Lua and loose Patterns

In Lua, how would one match 123, against a string that is 11122333, and find the 1 and 2 and 3? is there a pattern that can do this? rather than attaching individual character checks?

Upvotes: 3

Views: 133

Answers (1)

Egor Skriptunoff
Egor Skriptunoff

Reputation: 23767

local str = '11122333'
str = str:gsub('.','\0%0%0'):gsub('(.)%z%1',''):gsub('%z.','')

Upvotes: 2

Related Questions