I asked before but now I’m realizing some things I haven’t before. Ideally, if a user entered something as absurd as " 1.232 + a3" I would want everything unnecessary like the spaces and letters to be parsed out and leave in the numbers (up to two decimal places is all I need). I tried to clean up the string using
[lua]selfImput1.text = string.gsub(stringInput.text, “[%s+%a+%p+]”, “”) [/lua] but I would need it to leave the decimal points alone and not to delete the “+” symbol.
After that, I was told that I can capture the values in the string using something like this:
[lua] leftOperand, operator, rightOperand = string:match(“10 + 20”, “(%d+)(%x)(%d+)”) [/lua]
And I’m assuming at this point I just add together the left and right operands since I’m only allowing addition to be used.
Here’s a link to my other post. Someone else also posted a table to clean the characters but I am very unfamiliar with tables and feel I am only guessing what each line means.
https://developer.coronalabs.com/forum/2013/01/21/it-possible-allow-user-calculate-my-textfield
Thanks for any help!