..:D&G:.. Posted August 17, 2015 Share Posted August 17, 2015 Hello peeps, is there a way of getting a text using guiGetText and check if it's a normal whole number? I want to output an error if the player enters a number with , or ., or a number and a letter, I want to check if the number the player entered in a memo is a whole number. Thanks. Link to comment
Moderators Citizen Posted August 17, 2015 Moderators Share Posted August 17, 2015 Hi, You can do it with a simple regex: function isValidNumber(number) return string.find(number, "^[+-]?%d+$") and true or false end Explainations:^begining of the string [+-]?followed by an optional + or a - %d+followed by a digit (so from 0 to 9) one or multiple times $followed by the end of the string (so nothing should be after the whole number) Test it here: http://ideone.com/pyVUMb Regards, Citizen Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now