Hello.
I am trying to validate text input from an input box.
What I need is for the character string to match a word (not numbers) or two words separated by a space
the function is:
This only works if the string contains two words and a space, but I also want it to work if the string contains only one word.
I have tried this:
But don't work.
I am trying to validate text input from an input box.
What I need is for the character string to match a word (not numbers) or two words separated by a space
the function is:
function comprobar_hechizo (dhech)
local match = string.match (dhech, "^%%a+%%s%%a+$")
if not n then
utils.msgbox ("the spell name can only contain letters and spaces", "Error")
return false
end
return true
end
This only works if the string contains two words and a space, but I also want it to work if the string contains only one word.
I have tried this:
local match = string.match (dhech, "^%%a+|%%a+%%s%%a+$")
But don't work.