SweetNGX
SweetNGX

Reputation: 163

LUA / URL Query Parsing

How do I serialize the following url with lua?
Is it possible with the "match"?

http://example.com/go.php?user=stack&pass=overflow

Domain: example.com
User: stack
Pass: overflow

Upvotes: 0

Views: 631

Answers (1)

lhf
lhf

Reputation: 72312

Try this:

s="http://example.com/go.php?user=stack&pass=overflow"
d,u,p=s:match("http://(.+)/.*user=(.-)&pass=(.+)")
print(d,u,p)

Upvotes: 1

Related Questions