title: Why is this lua gsub not working?
body: <p>I have some lua code that is part of a rest api.  I'm extending it to handle redirects.
  However, I'm having trouble with a gsub.</p>
  
  <pre><code>msg=POST /v2/keys/message?recursive=true&amp;value=hello%20world HTTP/1.1
  Host: 172.17.8.101:4001
  Content-Length: 0
  Accept: */*, application/json, application/x-www-form-urlencoded, text/plain
  </code></pre>
  
  <p>I want to replace </p>
  
  <pre><code>path = "blabla"
  msg = msg:gsub("^%w* ([^\r\n]*)\r\n.*", path .. " HTTP/1.1")
  </code></pre>
  
  <p>So that the result is:</p>
  
  <pre><code>msg=POST blabla HTTP/1.1
  Host: 172.17.8.101:4001
  Content-Length: 0
  Accept: */*, application/json, application/x-www-form-urlencoded, text/plain
  </code></pre>
  
  <p>But everything I've tried didn't match and didn't replace.  I think I just fundamentally misunderstand how lua gsub and it's pattern matching works.  What's wrong with the gsub?</p>