Matching a href spec with Lua regex

vamshi nginx-forum at nginx.us
Fri Jun 27 16:57:09 UTC 2014


As usual, found my error. 

The following is properly matcing the regex :

                local escUri = function (m)
                    local _str = "href=\\"http://10.0.9.44/?_redir_="
                    _str = _str .. ngx.escape_uri(m[1]) .. "\\""
                    return _str
                end

                local newStr, n, err = ngx.re.gsub(ngx.arg[1],
"href=\\"(.*)\\"", escUri, "ijox")
                print(ngx.arg[1]) --> still original text 


>From my debug logs, I can see that the regex susbstitution is happening
properly. But the href still remains the same. Probably because of chunked
data.

I will try to aggregate the response body and then do the substitution. But
if someone sees anything wrong, your help would be appreciated. 

-Vamshi

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,251234,251243#msg-251243



More information about the nginx mailing list