I've been searching the net and Google news groups for a preg_match
expression that will return true on strings containing (uppercase and
lowercase) characters of A-Z, 0-9 and for instance Swedish characters Å Ä Ö.
It should return false on strings containing stuff like -#¤%\"[]()=?&/.
The thing is, I don't want to specifically allow Å Ä Ö, I want a more
general rule in case other characters like ü or ø turn up. Is this possible
to do?
I've tried
preg_match("/^\w+$/", $string)
and
preg_match("/^[[:alpha:]]+$/", $string)
but both returns false on everything except a-z A-Z.
I'm going to use it to test a receiver's name ($to_name) before putting it
in an e-mail header like "$to_name <$to_email>"; The names are entered in a
text field by my users and I want to test the name so it won't mess up the
e-mail header causing the e-mail to fail.
Any help would be greatly appreciated. Thank you.
Daniel