2
votes

I want to parse informations in GET by lua's string.match.

My information in GET is: "SSID=My+ssid&PASS=mypass123&IP=192.168.1.100".

I use this code:

local _GET = {}
vars="SSID=My+ssid&PASS=mypass123&IP=192.168.1.100"
print(vars)
            for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
                _GET[k] = v
        print(k)
        print(v)
            end

And my result is:

SSID
My
PASS
mypass123
IP
192

How can I get full information? For exmaple not only first part of digits in IP address?

1

1 Answers

2
votes

Try this:

vars="SSID=My+ssid&PASS=mypass123&IP=192.168.1.100"
vars=vars.."&"
for k, v in string.gmatch(vars, "(%w+)=(.-)&") do
        print(k)
        print(v)
end