View Single Post
10-01-22, 08:16 AM   #2
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
You can use gsub to do the replacement

Lua Code:
  1. line = 'frame1 and frame2 or frame3'
  2.  
  3.  
  4. local keywords = {
  5.     ["and"] = "and",
  6.     ["or"] = "or",
  7. }
  8.  
  9. print(line:gsub("[_%w]+", function(word)
  10.     return keywords[word] or string.format("_G[%q]", word)
  11. end))
  Reply With Quote