Jump to content

[HELP] Check if string has special characters


..:D&G:..

Recommended Posts

Posted

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.

Posted

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

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...