I'm really struggling with this.. I'm trying to get only the first 2 per line in the string printed but it doesn't work perfectly
local pattern = "(%w+)%s?(%w+).-%d+" local get = [[Start Tackle Normal Physical 50 100% 35 Start Harden Normal Status ? ?% 30 Start Headbutt Normal Physical 70 100% 15]] for level, move in get:gmatch(pattern) do print(level.." "..move) end
Here is my output:
Start Tackle 10 0 Start Harden Start Headbutt 10 0
It should only be
Start Tackle Start Harden Start Headbutt
This is what you need to produce the results you want.
local pattern = "(%w+)%s?(%w+).-\n" local get = [[Start Tackle Normal Physical 50 100% 35 Start Harden Normal Status ? ?% 30 Start Headbutt Normal Physical 70 100% 15 ]] for level, move in get:gmatch(pattern) do print(level.." "..move) end
The output
Start Tackle Start Harden Start Headbutt
the reason it does this is because it has digits to get rid of digits just change the pattern
to this
pattern = "(%w+)%s?(%w+)"
if you use the %d then it will also include digits