Sign in to follow this  
Stealthy Serval

string.match only looking at first character

Recommended Posts

Hey all, so I'm wanting to look at the string from a characters name and ensure that all characters are A-Z (no numbers or special characters)

But unfortunately I can only get it to look at the first character of the string.

if not string.find(fName, "^%a") or not string.find(lName,"^%a")then
    if isTimer(cTimer)then killTimer(cTimer) end
    guiSetText(createChar.errorLab,"Invalid characters. (A-Z only)")
    cTimer = setTimer(fadeError,3000,1)
	return
end

I've switched between string.find() and string.match() to try them both, and I've also switched the code from if not to if and else, but still not luck.

Share this post


Link to post

I was able to fix this problem by adding "+$" to the end of the string.find() calls.

if not string.find(fName, "^%a+$") or not string.find(lName,"^%a+$")then
    if isTimer(cTimer)then killTimer(cTimer) end
    guiSetText(createChar.errorLab,"Invalid characters. (A-Z only)")
    cTimer = setTimer(fadeError,3000,1)
	return
end

I'm not sure if this is the most effective way or not, but it fixed it!

Edited by Stealthy Serval

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.