I'm working on a graphing program and the function of a line needs to be printed to the screen. However, if a math function is in the line's function (ex:)
function(x) return math.atan(x) end
then I want to remove the 'math.' part. I also want to remove any spaces in the function, as well as other patterns I may think of in the future. This is what I currently have (simplified, of course)
local func = "math.atan( x )"
print(func:gsub("[math%. ]", "")) --look for math. or a space
--OUTPUT: n(x)
I realize I don't need the spaces in-between the parenthesis, but those are there just for testing purposes. I was hoping for the output to say "atan(x)"
m,a,t,h,., and space, notmath.. There's no way to do this without multiple calls togsub