title: Regular expressions in Lua using .gsub()
body: <p>Ok, I think I overcomplicated things and now I'm lost. Basically, I need to translate this, from Perl to Lua:</p>
  
  <pre><code>my $mem;
  my $memfree;
  open(FILE, 'proc/meminfo');
  while (&lt;FILE&gt;)
  {
      if (m/MemTotal/)
      {
          $mem = $_;
          $mem =~ s/.*:(.*)/$1/;
      }
  
  }
  close(FILE);
  </code></pre>
  
  <p>So far I've written this:</p>
  
  <pre><code>for Line in io.lines("/proc/meminfo") do
      if Line:find("MemTotal") then
          Mem = Line
          Mem = string.gsub(Mem, ".*", ".*", 1)
      end
  end
  </code></pre>
  
  <p>But it is obviously wrong. What am I not getting? I understand why it is wrong, and what it is actually doing and why when I do</p>
  
  <pre><code>print(Mem)
  </code></pre>
  
  <p>it returns</p>
  
  <pre><code>.*
  </code></pre>
  
  <p>but I don't understand what is the proper way to do it. Regular expressions confuse me!</p>