title: how to extracted updated string after calling string.gsub in lua?
body: <p><strong>Problem Description:</strong> </p>
  
  <p>HI there.  I'm trying to figure out how to use the lua function "string.gsub".  I've been reading the manual which says: </p>
  
  <blockquote>
    <p>This is a very powerful function and can be used in multiple ways.
    Used simply it can replace all instances of the pattern provided with
    the replacement. A pair of values is returned, the modified string and
    the number of substitutions made. The optional fourth argument n can
    be used to limit the number of substitutions made:</p>
  </blockquote>
  
  <pre><code>&gt; = string.gsub("Hello banana", "banana", "Lua user")
  Hello Lua user  1
  &gt; = string.gsub("banana", "a", "A", 2)  -- limit substitutions made to 2
  bAnAna  2
  </code></pre>
  
  <h2>Question</h2>
  
  <p>When it says that a pair of values is returned; how do I get the new string value? </p>
  
  <h2>Code</h2>
  
  <pre><code>local email_filename = "/var/log/test.txt"
  local email_contents_file_exists = function(filename)
       file = io.open(filename, "r")
       if file == nil then
            return false
       else
            file.close(file)
            return true
        end
  end
  local read_email_contents_file = function()
     print('inside the function')
     if not email_contents_file_exists(email_filename) then 
        return false
     end
     local f = io.open(email_filename, "rb")
     local content = f:read("*all")
     f:close()
     print(content)
     --content = string.gsub(content, '[username]', 'myusername')
     --local tmp {}
     --tmp = string.gsub(content, '[username]', 'myusername')
     print(string.gsub(content, '[username]', 'myusername'))
     return content
  end
  local test = read_email_contents_file()
  </code></pre>
  
  <p><strong>What I've Tried So Far:</strong></p>
  
  <p>I've tried just printing the results, as you see above. That returns a bunch of garbled text. Tried saving to original string and I've also tried saving the results to an array (<code>local tmp = {}</code>)</p>
  
  <p>Any suggestions?</p>