2

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 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.