title: Pattern match a string in Lua
body: <p>I have the following string to split into a table using Lua:
  (the data is aligned with each other. I did not find out how to write format it like that on this site)</p>
  
  <blockquote>
    <p>IP:         192.168.128.12<br/>
    MAC:         AF:3G:9F:c9:32:2E<br/>
    Expires:     Fri Aug 13 20:04:53 2010<br/>
    Time Left:   11040 seconds<br></p>
  </blockquote>
  
  <p>the result should be put into a table like this:</p>
  
  <blockquote>
    <p>t = {"IP" : "192.168.128.12", "MAC" : "AF:3G:9F:c9:32:2E", "Expires" : "Fri Aug 13 20:04:53 2010", "Time Left" : "11040 seconds"}</p>
  </blockquote>
  
  <p>I tried with:</p>
  
  <pre><code>for k,v in string.gmatch(data, "([%w]+):([%w%p%s]+\n") do
    t[k] = v
  end
  </code></pre>
  
  <p>That was my best attempt.</p>