I need a regex that checks if a string only contain letters(a-z) and that the first letter is uppercase, you cant have 2 letters in a word uppercase Like: THomas or THomAS but Thomas Anderson (Thomas anderson too) would be valid
look:
The Magician Of The Elfs would be valid but not ThE MaGiCiAN oF ThE ELFS
if (!preg_match("??", $name)) {
echo "Invalid name!";
}
hope you understand!
Tomasz
Invalid:
MaGIciaN Of The ELFz
THomas anderson
Valid:
Magician of the elfs
Magician Of the Elfs
Magician of The elfs
Thomas Anderson
Thomas anderson
Basically i dont want it to be possible to have more than 1 capitalized letter in a word, not sentence.
You can also describe the character by its Unicode character properties:
Edit Since you changed your requirements, try this regular expression:
Now the first character or each word can be an uppercase letter or a lowercase letter.