The character ?
on its own, acts as a pattern modifier. This is why you get nil
result. Use a %
to escape this.
str = "GET /?state=authenticated&code=U946s9lHouBGWy8o45bXSRSXGzTqd0Ys HTTP/1.1"
print( str:match("GET /%?state=(%w+)&code=(%w+)") )
Here is working output: https://eval.in/33065
EDIT
Here is another example for the same, without escaping the ?
character. This is just to elaborate my point. :)