title: String manipulation in Lua with special characters
body: <p>I would like to trim a string in Lua but I'm struggling I think because of the special characters in the string. </p>
  
  <p>E.g. <code>str = "RG Ph 0%/15.00bpm"</code></p>
  
  <p>I would like to remove everything after and including the <code>"/"</code></p>
  
  <p>so that<code>str = "RG Ph 0%"</code></p>
  
  <p>I have found the following code but I don't think it handles the <code>"%"</code> and <code>"/"</code> properly:</p>
  
  <pre><code>local string_gsub = string.gsub
  
  function string.trimRight( str, char )          
  char = char or "%s"          
  return ( string_gsub( str, "(" .. char .. "*)$", "" ) )  
  end  
  </code></pre>
  
  <p>Any ideas?</p>