Checking a string for non-alphanumeric chars?

I have been trying to figure this out for way too long now, can somebody give me a tip?
I have tried using the string.find with a list of alphanumeric chars, but i cant find a way to say ‘if the string contains a char that is not in this list…’

I know how to check a string for certain chars, but i want to check for anything but alphanumeric because listing all possible chars is not possible.
Thanks

[lua]
found = str:find( “%W” )
[/lua]

Will be nil if the string str contains only alphanumeric numbers.

You want to use patterns:

[lua]local function containsWeirdChars( str )
return #string.match( str, “%w+” ) == #str
end[/lua]

Damn you :ninja: Still practicing patterns… :frowning:

Thanks, wow i didn’t realise Lua could use regular expressions! That is useful.
Random question, if there any way to get my server to send the client the gamemode it is using? I have made a gamemode and when i join my server it says “Could not start gamemode”…

That means there’s an error preventing it from running.

The error was



Couldn't include file 'OneScape/gamemode/cl_init.lua' (File not found)
**********************************************
**********************************************
********** COULDN'T LOAD GAMEMODE!! **********
**********************************************
**********************************************

There was a problem opening the gamemode file 'OneScape/gamemode/cl_init.lua'


This is because i dont have the gamemode on my PC, i tried removing it to check my server sends me the files because obviously people joining my server won’t have the gamemode in their garrys mod folder.
Or am i doing it wrong?

As you can read the server didn’t send you the clientside file. Use AddCSLuaFile.

Yeah i did have that, turns out it was an error in the code - i never realised it was such a fatal error that was stopping the gamemode from being sent to the client. All working nicely now thanks!