Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 491
Cyberience Avatar asked Sep 04 '26 14:09

Cyberience


1 Answers

local str = '11122333'
str = str:gsub('.','\0%0%0'):gsub('(.)%z%1',''):gsub('%z.','')
like image 70
Egor Skriptunoff Avatar answered Sep 06 '26 03:09

Egor Skriptunoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!