..:D&G:.. Posted January 31, 2018 Share Posted January 31, 2018 Hi, so it's been a while since I've used this... How can I check if a string has special characters like /\';"£$!@~ etc and also numbers? I need the string to only be a string of letters. I tried this but the name can still have / in it when the string is "MyString/" local function checkValidCharacterName(theText) if(string.find ( theText, "[^a-zA-Z]")) then return false else return true end end Thanks. Link to comment
NeXuS™ Posted January 31, 2018 Share Posted January 31, 2018 What about string.find(theText, "%A") Link to comment
..:D&G:.. Posted January 31, 2018 Author Share Posted January 31, 2018 7 minutes ago, NeXuS™ said: What about string.find(theText, "%A") Nope, I can still add a / at the end of the string and it works Link to comment
NeXuS™ Posted January 31, 2018 Share Posted January 31, 2018 Your code has to be somewhere wrong. val = string.find("MyName", "%A") outputChatBox(tostring(val)) -- nil val = string.find("MyName/", "%A") outputChatBox(tostring(val)) -- 7 Link to comment
..:D&G:.. Posted January 31, 2018 Author Share Posted January 31, 2018 (edited) 23 minutes ago, NeXuS™ said: Your code has to be somewhere wrong. val = string.find("MyName", "%A") outputChatBox(tostring(val)) -- nil val = string.find("MyName/", "%A") outputChatBox(tostring(val)) -- 7 Didn't know it has to return a number or nil, thanks Edited January 31, 2018 by ..:D&G:.. 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