First, note that Lua patterns are not regular expressions; they are their own simpler matching language (with various advantages and disadvantages).
In the spec that I linked above, and for this answer , there is no strip operator in the Lua template. To get this functionality, you need to use a more powerful Lua construct (like LPEG or Lua Regex Library ).