title: Lua iterating string for whitespace
body: <pre><code>whiteSpace = 0
  foo = "foo bar"
  
  for i = 1, #foo do
      if (string.sub(foo, i, i) == "%") then
          whiteSpace = whiteSpace + 1
      end
  end
  
  print(whiteSpace)
  </code></pre>
  
  <p>I'm trying to loop through this string in each character, check if it is whitespace. If the character is whitespace, I want to increment the whiteSpace variable and output it at the end. But for some reason when I execute it, it always returns 0, even though there is clearly whitespace within the foo string.</p>
  
  <p>I've used <code>"%"</code>, <code>"%s"</code> and <code>""</code> with no avail. Pretty clueless right now.</p>